Difference between revisions of "Vim tweaks"

From lippmann wiki
Jump to: navigation, search
Line 1: Line 1:
 +
=viewports=
 
I often split my vim session so I can compare textfiles when coding some basic php stuff.
 
I often split my vim session so I can compare textfiles when coding some basic php stuff.
 
To split a page with vim, run :sp <filename> or :vsp <filename>.
 
To split a page with vim, run :sp <filename> or :vsp <filename>.

Revision as of 19:02, 2 November 2013

viewports

I often split my vim session so I can compare textfiles when coding some basic php stuff. To split a page with vim, run :sp <filename> or :vsp <filename>.

sp will split the Vim window horizontally. The existing file text will be shown on the bottom or top half of the screen, and the newly opened file will be shown above or below this text.
vsp will split the Vim window vertically. The existing file text will be shown on the left or right half of the screen, and the newly opened file will be shown on the remaining part of the screen.

To switch between the views (also referred to as viewports) you use ctrl-w in combination with other keys:

Ctrl-w Ctrl-w moves between Vim viewports.
Ctrl-w j moves one viewport down.
Ctrl-w k moves one viewport up.
Ctrl-w h moves one viewport to the left.
Ctrl-w l moves one viewport to the right.
Ctrl-w = tells Vim to resize viewports to be of equal size.
Ctrl-w - reduce active viewport by one line.
Ctrl-w + increase active viewport by one line.
Ctrl-w q will close the active window.
Ctrl-w r will rotate windows to the right.
Ctrl-w R will rotate windows to the left.