76 Shortcuts for Vim (Linux)  [edit]

minimize Hide all  maximize Show all

minusplus1. Cursor Movement
h Move left
j Move down
k Move up
l Move right
w Jump by start of words
W Jump by words
e Jump to end of words
E Jump to end of words (no punctuation)
b Jump backward by words (punctuation considered words)
B Jump backward by words (no punctuation)
0 Start of line
^ First non-blank character of line
$ End of line
G Go To command (prefix with number)
i Start insert mode at cursor
I Insert at the beginning of the line
a Append after the cursor
A Append at the end of the line
o Open (append) blank line below current line (no need to press return)
O Open blank line above current line
ea Append at end word
Esc Exit insert mode

▲ up

minusplus2. Editing
r Replace a single character (does not use insert mode)
J Join line below to the current one
cc Change (replace) an entire line
cw Change (replace) to the end of word
c$ Change (replace) to the end of line
s Delete character at cursor and subsitute text
S Delete line at cursor and substitute text (same as cc)
xp Transpose two letters (delete and paste, technically)
u Undo
. Repeat last command

▲ up

minusplus3. Making text (Visual mode)
v Start visual mode, mark lines, then do command (such as y-yank)
V Start Linewise visual mode
o Move to other end of marked area
Ctrl+v Start visual block mode
O Move to other corner of block
aw Mark a word
ab A () block (with braces)
aB A {} block (with brackets)
ib Inner () block
iB Inner {} block
Esc Exit visual mode

▲ up

minusplus4. Visual commands
> Shift right
< Shift left
y yank (copy)marked text
d Delete marked text
~ Switch case

▲ up

minusplus5. Cut and Paste
yy Yank (copy) a line
2yy Yank 2 lines
yw Yank word
y$ Yank to end of line
p Put (paste) the clipboard after cursor
P Put (paste) before cursor
dd Delete (cut) a line
dw Delete (cut) the current word
x Delete (cut) current character

▲ up

minusplus6. Exiting
:w Write (save) the file, but don't exit
:wq Write (save) and quit
:q Quit (fails if anything has changed)
:q! Quit and throw away changes

▲ up

minusplus7. Search/Replace
/pattern Search for pattern
?patten Search backward for pattern
n Repeat search in same direction
N Repeat search in opposite direction
:%s/old/new/g Replace all old with new throughout file
:%s/old/new/gc Replace all old with new throughout file with confirmations

▲ up

minusplus8. Working with multiple files
:e filename Edit a file in a new buffer
:bnext Go to next buffer
:bprev Go to previous buffer
:bd Delete a buffer (close a file)
:sp filename Open a file in a new buffer and split window
Ctrl+ws Split windows
Ctrl+ww Switch between windows
Ctrl+wq Quit a window
Ctrl+wv Split windows vertically

▲ up


Uploaded by Chirag, updated on 7/13/2017