cheng
cheng

Reputation: 6696

vi vsplit, command needed

say I have two files: file1 and file2

is there a single command that I can run on terminal to open ONE vi screen which is vertically splited and show file1 and file2 on either side?

Thanks, Cheng

Upvotes: 1

Views: 643

Answers (2)

louie_45
louie_45

Reputation: 9

Use vi command:
:h CTRL-W

read the related part:
2.2 Window commands CTRL-W

Upvotes: 1

kiddorails
kiddorails

Reputation: 13014

@cheng I asked this on #vim channel briefly some weeks ago. At that time, could come up with this solution: In example below, I opened file1.txt first in vi, and felt need of file2.txt splitted in vertical frame.

vi file1.txt
Ctrl+W+v 
:sp file2.txt
Ctrl+W+w
:q

Initially, it opens the file1.txt in full screen, then 2nd command, splits that file on vertical pane. 3rd command opens file2.txt in horizontal splitted mode. 4th one jumps over to the first vertical splitted module and last one closes that.

Obviously, this approach is just usable when you have to open the file in ongoing vim session. As @ravi mentioned in link, vim -o file1.txt file2.txt at start will do the same job.

I will highly appreciate the simpler approach for the desired task. :)

Upvotes: 2

Related Questions