Skip to content

Instantly share code, notes, and snippets.

@maiduchuy
Last active October 5, 2017 16:22
Show Gist options
  • Save maiduchuy/d5ec3b66ab57194fcd18434386574273 to your computer and use it in GitHub Desktop.
Save maiduchuy/d5ec3b66ab57194fcd18434386574273 to your computer and use it in GitHub Desktop.

Commonly used vim commands

For basic vim commands, run vimtutor in your terminal. It is recommended to go over this before you read further. Below are more advanced commands

In normal mode

Commands Shortcuts
toggle NerdTree \
toggle NerdTree and jump to the current file `
quickly search for a file <ctrl>p
quickly search for a file that was opened recently <ctrl>pf
split the view horizontally :sp
split the view vertically :vs
comment / uncomment ,c<space>
indent >
unindent <
select same words <ctrl>n
select a block, excluding the parent wrapper vii
select a block, including the the parent wrapper vai
go to the next character 'x' in the same line fx
go to the previous character 'x'in the same line Fx
capitalize/uncapitalize a character or a block ~
go to the right pane <ctrl>l
go to the left pane <ctrl>h
go to the upper pane <ctrl>k
go to the lower pane <ctrl>j
search for the word under cursor ,vv
replace the word under cursor ,vr
search in working directory Grep <string/regex>
replace in working directory Replace <string/regex>
go to the corresponding opening / closing braces %
find the word under the cursor in the current file *
show/hide highligts after searching <space>
fold all code blocks to the root level zM
fold all code blocks for 1 level zm
unfold all code blocks for 1 level zr
unfold all code blocks zR
unfold the code block under cursor for only 1 level zo
unfold the code block under cursor for all levels zO
quickly jump to a string by first 2 characters of the string s<first 2 chars>
go back to the recent file ^

working with Git

Commands Shorcuts
go to the next change in the file ]c
go to the previous change in the file [c
git status :Gstatus
git commit :Gcommit
git push :Gpush
git blame :Gblame
other git commands :Git <command>

In NerdTree

Commands Shorcuts
show available commands ?
go to the next GIT change in the tree ]c
go to the previous GIT change in the tree [c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment