Hello Vim !
This blog or you can say cheat sheet covers the basic commands/keys you need to know to start using Vim. Initially, you will feel that it's a lot to remember but just keep practicing. The first day you'll hate it. In a week you'll understand it and by a month you'll start loving it.
The best way to utilize this cheat sheet is to open/create a file and practice these commands one by one.
So let's begin ๐
Exiting
:w
- save file:wq
- save and quit (can also use :x
):q
- quit:q!
- quit without save:qa!
- close all files and abandon changes ZZ
- save and quit
Navigating
arrows - to navigate up down left rightl
- righth
- leftj
- downk
- up
Document
}
- move down 1 block of code{
- move up 1 block of codegg
- move to the top of the fileG
- move to the bottom of the file:<num>
- go to line <num>
Words
w
- move to the next word on the lineb
- move to the previous word on the linege
- move to the previous end of word
e
- move to next end of word
Line
0
(zero) -move to beginning of the line$
- move to end of the line^
- move to first character of the linet<char>
- move cursor just before <char>
on the linef<char>
- move cursor on the <char>
on the line%
- move cursor to matching ),], or }
Clipboard
x
- delete character
<num>x
- delete <num>
characters to right of cursor
dd
- delete current line(cut)
yy
- yank line(copy)
p
- paste below
P
- paste above
u
- undo
ctrl R
- redo
Modes
i
- enter insert modeesc
- escape any mode and enter command modeo
- insert 1 line below and enter insert modeO
- insert 1 line above and enter insert mode
V
- visual mode (selects 1 line per movement)v
- visual mode (selects 1 letter per movement)V + d
- delete selected partctrl V + movements
- selects column
Misc Operators and combos
cw
- change word -> it deletes a word and enters insert modedw
- delete to next worddb
- delete to beginning of word
D
- deletes everything to right of cursorC
- deletes everything to right of cursor and enter insert mode
dt<char>
- delete till <char>
excluding <char>
ct<char>
- delete till <char>
excluding <char>
and enter insert mode
*
- toggle between instances of the word where the cursor is present
t<char>;
- move to <char>
on the line on every press of ;
zz
- scrolls the page such that the line on which the cursor is right now is brought to the center of page...i.e. centers the work page
0w
- move to first character of lined<num>w
- delete <num>
words
a
- move right by 1 letter and enter insert modeA
- move to end of line and enter insert mode
~
- toggle case of word (uppercase/lowercase)
.
- re-runs the last command
r<anything>
- replace current letter to <anything>
>>
- indent current line<<
- remove indent from current line
Wrap Up
There is a lot that I haven't covered yet like macros, complex combos, plugin setup, configuring vim and many other keybindings. This blog is just meant to be for beginners. Once you get comfortable with Vim it's easy to explore these and try it out.
I hope you found this cheat sheet helpful and keep it handy for a quick reference. If you want me to add more information to this blog or need any help let me know in the comments.
Let's connect on LinkedIn
๐ Thanks for reading, See you next time.