vim modes
Normal mode
h - move left
j - move down
k - move up
l - move right
w - jump to next word
W - jump to next string
b - jump to previous word
B - jump to previous string
0 - move to first position in line
$ - move to end of the line
z + enter - move to the top
2gg or 2G - move to line 2
ctrl g show how many lines in file
delete
x - delete char where cursor is
X - delete char before cursor
dw - d - delete w - motion
dl - delete word on left
dk - delete up line
dh - delete down line
dj - delete word on right
d0 - delete all to begin line
dd or D- delete line
2dd or 2D- delete 2 lines
5dw - delete 5 words ( delete word 5 times)
3w - move to third word (repeat word motion 3 times)
d3w - delete 3 words 2d3w - delete 3 words 2 times
. - repeat last operation
cut,copy,paste
y then p - copy and paste before cursor
y then P - copy and paste after cursor
yy then p - copy line and paste
v then h,j,k,l to select text, then p - select text and paste
dd then p - cut line then paste after cursor line
dd then P - cut line then paste before cursor line
In the mapping section we will add shortcuts to making typing longer commands easier. This will save you key strokes and lots of time, especially for long commands.
Key mapping syntax is like this:
map_mode <what_you_type> <what_is_executed>
Here are a few popular mapping modes and probably the most useful and important.
nnoremap – Allows you to map keys in normal mode. inoremap – Allows you to map keys in insert mode. vnoremap – Allows you to map keys in visual mode.
~ : Changes the case of current character guu : Change current line from upper to lower. gUU : Change current LINE from lower to upper. guw : Change to end of current WORD from upper to lower. guaw : Change all of current WORD to lower. gUw : Change to end of current WORD from lower to upper. gUaw : Change all of current WORD to upper. g~~ : Invert case to entire line g~w : Invert case to current WORD guG : Change to lowercase until the end of document. gU) : Change until end of sentence to upper case gu} : Change to end of paragraph to lower case gU5j : Change 5 lines below to upper case gu3k : Change 3 lines above to lower case