w
forward to beginning of the next wordW
forward to beginning of the next word (whitespace separates)e
forward to end of next wordE
forward to end of next word (whitespace separates)b
back to beginning of the previous wordB
back to beginning of the previous word (whitespace separates)ge
back to end of the next wordgE
back to end of the next word (whitespace separates)
fn
find 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.tn
find and move to (until) the character preceding the next occurrence ofn
. As above,;
repeats, and,
goes back one match.Fn
find and move to the previous occurrence ofn
.;
repeats,,
goes back one match.Tn
find and move to (unTil) the character following the next occurence ofn
.;
repeats,,
goes back one match.
/term
search forwards forterm
?term
search backwards forterm
cfn
- change the text up to where you find the next occurrence ofn
cFn
- change the text back to where you Find the previous occurrence ofn
^f
forward a page/screen^b
back a page/screen^u
up half a page/screen^d
down half a page/screen
H
go to Head (top) or "High point" of screenM
go to Middle of screenL
go to Last line or "Low point" of screen
gg
first line of documentG
last line of document500G
line 500*
search forwards for word currently under cursor (use withn
andN
)#
search backward for word currently under cursor (use withN
andn
- note that direction is reversed)%
matching bracket, brace, square bracket - see matchit.vim for extended behavior
ma
set position of (book)marka
:marks
list currently defined marks'a
jump to rot for marka
- ```a
jump to row/column for mark
a`
i
insert at cursorI
insert at beginning of linea
append after cursorA
append at end of liner
replace a single characterR
replace any number of charactersc<motion>
change, e.g.cw
is change wordx
delete character under cursorX
delete character before cursord<motion>
delete, e.g.dw
is delete word,dd
is delete line
See http://vim.wikia.com/wiki/VimTip386 for more detailed info.
- press
v
(for visual mode) to start the selection (orV
to select whole lines, orCtrl-v
for a vertical block) - move the cursor to where you want the selection to end
- press
d
for delete (cut) ory
for yank (copy) - position the cursor where you want to paste
- press
P
orp
for 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 +