月曜日, 12月 14, 2009

Split Window in Vim

How do I open and edit multiple files under VIM text editor running under Ubuntu Linux / UNIX operating systems to improve my productivity?

My vi/vim cheatsheet

Vim documentation: windows


Open two windows
$ vim -o file1.txt resume.txt Start vim as follows to open two windows,split horizontally
$ vim -O /etc/passwd /etc/hosts The -O option allows to open two windows, split vertically
^W-sSplit current window in two horizontally
^W-vSplit current window in two vertically
^W-nOpen new empty window horizontally
:newOpen new empty window horizontally
:spOpen new empty window horizontally
:vspOpen new empty window vertically
:new /etc/hosts.denyOpen exiting file in a new windows horizontally
:sp /etc/hosts.denyOpen exiting file in a new windows horizontally
:vsp /etc/hosts.denyOpen exiting file in a new windows vertically
Switch from Horizontal split to Vertical split
^W-L Switch from horizontal to vertical split,
putting the current buffer on the right side of the vertical split.
^W-H Put it on the left
^W-Jbottom
^W-Ktop
Moving between windows
Key combination Action
^W-h move to the window on the left
^W-j move to the window below
^W-k move to the window above
^W-l move to the window on the right
^W-t move to the TOP window
^W-b move to the BOTTOM window
Close windows
^W-^Q Close the current windows
[ESC]-:qQuit current window
Resize Window
[ESC] - 5 - ^W - +Increase windows size by 5
[ESC] - 5 - W - -Decrease windows size by 5
Save and quit all windows
:wqall Save all changes in all windows and quite
:qall! Quits Vim and throws away all changes

0 件のコメント: