wforward to beginning of the next wordWforward to beginning of the next word (whitespace separates)eforward to end of next wordEforward to end of next word (whitespace separates)bback to beginning of the previous wordBback to beginning of the previous word (whitespace separates)geback to end of the next wordgEback to end of the next word (whitespace separates)
fnfind and move to the next occurrence ofn. You can follow this with a;to repeat the find/move. You can also use,to go back one match.tnfind and move to (until) the character preceding the next occurrence ofn. As above,;repeats, and,goes back one match.Fnfind and move to the previous occurrence ofn.;repeats,,goes back one match.Tnfind and move to (unTil) the character following the next occurence ofn.;repeats,,goes back one match.
/termsearch forwards forterm?termsearch backwards forterm
cfn- change the text up to where you find the next occurrence ofncFn- change the text back to where you Find the previous occurrence ofn
^fforward a page/screen^bback a page/screen^uup half a page/screen^ddown half a page/screen
Hgo to Head (top) or "High point" of screenMgo to Middle of screenLgo to Last line or "Low point" of screen
ggfirst line of documentGlast line of document500Gline 500*search forwards for word currently under cursor (use withnandN)#search backward for word currently under cursor (use withNandn- note that direction is reversed)%matching bracket, brace, square bracket - see matchit.vim for extended behavior
maset position of (book)marka:markslist currently defined marks'ajump to rot for marka- ```a
jump to row/column for marka`
iinsert at cursorIinsert at beginning of lineaappend after cursorAappend at end of linerreplace a single characterRreplace any number of charactersc<motion>change, e.g.cwis change wordxdelete character under cursorXdelete character before cursord<motion>delete, e.g.dwis delete word,ddis delete line
See http://vim.wikia.com/wiki/VimTip386 for more detailed info.
- press
v(for visual mode) to start the selection (orVto select whole lines, orCtrl-vfor a vertical block) - move the cursor to where you want the selection to end
- press
dfor delete (cut) oryfor yank (copy) - position the cursor where you want to paste
- press
Porpfor paste before or after cursor, respectively
For an excellent tutorial, see http://reefpoints.dockyard.com/2013/10/22/vim-buffers.html
- add a buffer:
:badd - list open buffers:
:ls - switch to alternate (
#) buffer:CTRL+6 - switch to previous buffer:
:bp - switch to next buffer:
:bn - switch to buffer x (where x is an integer):
:bx - delete (close) current buffer:
:bd - delete (close) buffers x and y:
:bd x y
For another excellent tutorial, see http://reefpoints.dockyard.com/2013/11/27/vim-windows.html
- split current window:
CTRL+w s - split current window vertically:
CTRL+w v - switch to window to left:
CTRL+w h - switch to window to right:
CTRL+w l - switch to window above:
CTRL+w k - switch to window below:
CTRL+w j - rotate windows:
CTRL+w r - rotate windows (opposite direction):
CTRL+w R - move current window the far left and use the full height of the screen:
CTRL-w H - move current window the far bottom and use the full width of the screen:
CTRL-w J - move current window the far top and full width of the screen:
CTRL-w K - move current window the far right and full height of the screen:
CTRL-w L - resize the windows equally :
CTRL-w = - incrementally increase the window to the right:
CTRL-w > - takes a parameter, e.g.
CTRL-w 20 > - incrementally increase the window to the left:
CTRL-w < - takes a parameter, e.g.
CTRL-w 20 < - incrementally decrease the window's height:
CTRL-w - - takes a parameter, e.g.
CTRL-w 10 - - incrementally increase the window's height:
CTRL-w + - takes a parameter, e.g.
CTRL-w 10 +