Vim Commands
Vim motions and keyboard shortcuts that make sense to me. Here is a list of motions and shortcuts that make sense to me. It's not meant to be an all-encompassing list of everything you can do, but a list of the ones that click for me.
Normal mode
File actions
Edit
a- addi- insertA- start editing at the beginning of the lineI- start editing at the end of the line.- redo the last commandciw- Change Inner Word
Folding code
zR- Open allzM- Collapse allzo- OpenzO- Open all from the current locationzc- ClosezC- Close all from the current locationza- Toggle current foldzi- Toggle code folding
Navigation
Left, down, up, right
hjkl
Start of line
0/ End of line$f @- move cursor to next occurrance of @, i.e.,fmove to nextt @- move cursor to character before next @.
Next word
w/ WORDWPrevious word
b/ WORDBEnd of next word
e/ WORDEPrevious blank line
{/ Next blank line}Previous sentence
(/ Next sentence)
Move cursor to first line of document
ggMove cursor to last line of document
GMove cursor to line
#-#GGo
#lines down -#j/ Go#lines up -#kMove up a screen
Ctrl uMove down a screen
Ctrl dGo to correct indentation level
S
Quit
ZZ
Auto-complete
Ctrl P/N
Selection
Select current word -
*
Buffers
:ls- List buffers:bn- Next buffer:bp- Previous buffer:bw- Close buffer:bd#- Close buffer #
Splits
:sp- split horizontally:vs- split verticallyZQ- close split
Macros
Recordings
Record:
q a(keystrokes)qPlay:
@ aPlay multiple (15) times:
15@a
Visual mode
Selection
Select a paragraph
Vap- select around the current paragraphVip- select inside the current paragraph
Select Word
viwandviW
Select tag
vit- select inside tag
Select block
v%- select from current position to next matching character
Select unitl next instance
v/foo- select from your current position to the next instance of foo, andnexpands to the next instance.
Copying
Copy a word and replace another word
To copy a word under the cursor, press
bveyTo replace the word under the cursor, press
bvep
Insert mode
Ctrl o- temporarily enter Normal modeCtrl w- delete the word to the left of the cursorCtrl u- delete from the cursor to the beginning of the line
Plugins
nvim-surround
Surround text with a character or a tag.
add with
ys{motion}{char}delete with
ds{char}change with
cs{target}{replacement}
ysiw)– add "(" and ")" around wordys$t- adds a tag around the text from cursor to the end of the line
ds"- delete " around textdst- delete tag around text
cs'"- change quotes from'to"
// Comment.nvim
Comment your code in style.
Normal mode
gcc- Toggles the current line using linewise commentgbc- Toggles the current line using blockwise comment
Visual mode
gc- Toggles the region using linewise commentgb- Toggles the region using blockwise comment