Wednesday, September 2, 2009

Split Screen on vi terminal

Sometimes we need to open multiple files even though we are aware of diff and many other ways of file comparison . We can open two or more files in split windows for comparison.
we will open two files in same terminal window..
open first file normally as we do 
$ vi first.txt
for opening second file in same vi display type 
$ :new second.txt
to navigate in between the windows use
ctrl + w
j     (move to lower window)
or
ctrl + w
k   (move to upper window)

for expanding a split window to full big screen 
:only
you can also open a new file by just typing 
:new 

if file opened by :new is now named , you wont be able to save it with just 
:wq 
instead u have to give 
:wq nameForNewFile.txt
Keep giving comments .. :)

1 comment:

  1. There is also
    $:sp newfile.txt
    which splits the screen horizontaly
    and
    $:vsp newfile.txt
    which splits the screen verticaly

    ReplyDelete