ViM trick: Split Screen in the Vim text browser

In this article I will show you how to split the screen in ViM. I have tested this tricks with vim 7.3.

Find your vim version:
$ vim --version | head -1
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 28 2012 13:52:43)

Screen Splitting in Vim:

Split screen from the shell:

Horizontal split:
$ vim -o file1.txt file2.txt

Vertical split:
$ vim -O file1.txt file2.txt

Open file with vim:
$ vim /path/to/file1
Split the screen into two horizontal screens: split /path/to/file2
:split /path/to/file2
Also, you can write only :sp /path/to/file2 for horizontal splitting.

Split the screen into two vertical screens: vsplit /path/to/file3
:vsplit /path/to/file3
Also, you can write only :vsp /path/to/file3 for vertical splitting.

Ctrl w w : switch between windows.

Type :help CTRL-W in vim to get all the split window operations.

To quit, you need to use an :q! or :wq for every opened window.

To increase the font size use Ctrl w + and to decrease it use Ctrl w – .

Also, if you want to toggle (or not) between screens with the scroll, use :set scrollbind (or :set noscrollbind)

Click here to find the other vim related articles.

Tagged with: , , , , , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *




Subscribe to get the latest Linux news and how to guides directly on your e-mail!