Sunday, March 29, 2009

vi keyboard shortcuts



vi keyboard shortcuts
Cursor control and position
Editing
File Handling
.
Cursor control and position
Lefth
Downj
Upk
Rightl (or spacebar)
Forward one wordw
Back one wordb
End of worde
Beginning of current sentence(
Beginning of next sentence)
Beginning of current paragraph{
Beginning of next paragraph}
Beginning of current section[[
Beginning of next section]]
Start of current line0
End of current line$
First non-white character of current line^
First character of next line+ or RETURN
First character of previous line-
character n of current linen |
Top line of current screenH
Middle line of current screenM
Last line of current screenL
n lines after top line of current screennH
n lines before last line of current screennL
Forward one screenCtrl-F
Back one screenCtrl-B
Down half a screenCtrl-D
Up half a screenCtrl-U
Display another line at bottom of screenCtrl-E
Display another line at top of screenCtrl-Y
Redraw screen with cursor at topz RETURN
Redraw screen with cursor in middlez .
Redraw screen with cursor at bottomz -
Redraw screen without re-positioningCtrl-L
Redraw screen without re-positioningCtrl-R
Search for text (forwards)/text
Repeat forward search/
Search for text (backwards)?text
Repeat previous search backwards?
Repeat previous searchn
Repeat previous search, but it opposite directionN
Go to line n after text/text/+n
Go to line n before text?text?-n
Find match of current parenthesis, brace, or bracket.%
Display line number of cursorCtrl-G
Move cursor to line number nnG
Move cursor to line number n:n
Move to last line in file
G
Editing
Append to end of current lineA
Insert before cursori
Insert at beginning of lineI
Open line above cursoro
Open line below cursorO
End of insert modeESC
Insert a tabCtrl-I
Move to next tab positionCtrl-T
Move back one characterBackspace
Delete current lineCtrl-U
Quote next characterCtrl-V
Move back one wordCtrl-W
Change wordcw
Change linecc
Change from current position to end of lineC
Delete current linedd
Delete n linesndd
Delete remainer of lineD
Delete worddw
Delete rest of paragraphd}
Delete back to start of lined^
Delete up to first occurance of patternc/pat
Delete up to next occurance of patterndn
Delete up to and including a on current linedfa
Delete up to, but not including, a on current linedta
Delete up to last line on screendL
Delete to end of filedG
Join two linesJ
Insert buffer after cursorp
Insert buffer before cursorP
Replace character with xrx
Replace text beginning at cursorRtext
Substitute characters
Substitute n charactersns
Substitute entire lineS
Undo last changeu
Restore current lineU
Delete current cursor positionx
Delete back one characterX
Delete previous n charactersnX
Repeat last change.
Reverse case~
Copy current line to new buffery
Copy current lineyy
Copy current line into buffer x"xyy
Delete and append into buffer x"Xd
Put contents of buffer x"xp
Copy up to next section headingy]]
Copy to end of wordye
File Handling
:wWrite file
:w!Write file (ignoring warnings)
:w! fileOverwrite file (ignoring warnings)
:wqWrite file and quit
:qQuit
:q!Quit (even if changes not saved)
:w fileWrite file as file, leaving original untouched
ZZQuit, only writing file if changed
:xQuit, only writing file if changed
:n1,n2w fileWrite lines n1 to n2 to file
:n1,n2w >> fileAppend lines n1 to n2 to file
:e file2Edit file2 (current file becomes alternate file)
:e!Reload file from disk (revert to previous saved version)
:e#Edit alternate file
%Display current filename
#Display alternate filename
:nEdit next file
:n!Edit next file (ignoring warnings)
:n filesSpecify new list of files
:r fileInsert file after cursor
:r !commandRun command, and insert output after current line

No comments: