Some Useful vim Commands - My vim Cheatsheet
Wednesday, April 9th, 2008
Updated: April 23rd, 2008
[WORK IN PROGRESS] Here is a list of commands that I use every day with vim, in no particular order. Out of a billion possible key combinations, I found these to be irreplaceable and simple enough to remember.
|
* |
search for the word under cursor (to the end of the file) |
|
# |
search for the word under cursor (to the top of the file) |
|
ctrl-p,ctrl-n |
suggest (p)revious or (n)ext autocomplete from the list of existing keywords in the file or included files (!). |
|
:go NNN |
go to byte NNN |
|
. |
redo last command |
|
/SEARCH TERM |
search document for SEARCH TERM |
|
:%s/FOO/BAR/gci |
replace FOO with BAR (g)lobally, case (i)insensitively, and asking for (c)onfirmation |
|
n (N) |
next (previous) search result |
|
% |
find and jump to a matching brace or parenthesis |
|
u |
undo |
|
ctrl-r |
redo |
|
r CHAR |
replace character under curson with CHAR |
|
i |
start editing before current character |
|
I |
start editing in the beginning of current line |
|
a |
start editing after current character |
|
A |
start editing at the end of current line |
|
o |
start editing on the next line |
|
O |
start editing on the previous line |
|
:wq or ZZ |
write file and exit |
|
ctrl-v |
visual block select (rectangular) |
|
shift-v |
visual line select |
|
ctrl(or shift)-v y or d |
copy or delete selected text |
|
yy |
yank (copy) current line |
|
yNNN arrow up/down |
yank NNN lines above or below |
|
p |
paste the yanked buffer |
|
cw |
change word (delete word under cursor and go into edit mode) |
|
cNw |
change N words |
|
e! |
reload the file (revert) |

(No Ratings Yet)
beer planet is Artem Russakovskii's blog. Artem is a software engineer at
April 11th, 2008 at 10:20 am
Nice sheet, I wrote a few of these down for myself. You're missing some good ones though:
When in visual select mode:
x to "cut" instead of Yank
> to "tab" the visual block
< to "untab" the visual block
D to delete characters on the line after the cursor
dd to delete the line
(N)dd to delete N number of lines (10dd to delete 10 lines)
G to end of file
:q! exit without saving
April 11th, 2008 at 1:02 pm
April 15th, 2008 at 5:33 am
very cool !!!
I didn't realize anyone used VI any more except those of us developing Unix code.
Good Stuff !!!!
April 22nd, 2008 at 8:55 pm