Skip to content

Instantly share code, notes, and snippets.

@gricard
Last active November 27, 2019 20:45
Show Gist options
  • Select an option

  • Save gricard/c94ccda5f591a6ad269a3b45a8db7afd to your computer and use it in GitHub Desktop.

Select an option

Save gricard/c94ccda5f591a6ad269a3b45a8db7afd to your computer and use it in GitHub Desktop.
VIM
:q quit
:q! quit without saving
:w save changes
:wq save and exit
MISC
. repeat last command
NAVIGATION
h move left
j move down
k move up
l move right
w go to start of next word
b go to start of prev word
e go to end of word
( start of sentence / go to prev empty line before code
) end of sentence /go to next empty line before code
{ start of paragraph/code block
} end of paragraph/code block
C-f page down
C-b page up
# enter line # and hit enter
^ go to beginning of text in current line
0 go to beginning of line
$ go to end of line
H top of screen
M middle of screen
L bottom of screen
* go to next instance of word at cursor
# go to prev instance of word at cursor
% go to matching bracket
GO
gg top of file
G end of file
gd go to definition
EDITING
i insert
a append
A append at end of line
D delete to end of line
C change to end of line
r replace a charater
x delete character
O insert line above
c change / delete & insert
d delete
dd delete line
dw delete word
u undo last command
uu undo last block of commands
C-r redo
SELECTING
v select by letter
V select by line
COPY/PASTE
yy copy (yank) a line
yw copy word
y$ copy to end of line
Vjjy select next two lines and copy
p paste after
P paste before
REGISTERS
"k___ ___ = command done on register k
"kyy copy current line into register k
"kp paste contents of register p after cursor
:reg list registers
"+ OS clipboard
"/ last search command
": last command
"_ black hole register (/dev/null basically)
INDENT
> shift right
< shift left
SEARCH
/text find text (fwd)
?text find text (rev)
n go to next match
N go to prev match
SEARCH & REPLACE
:%s/[pattern]/[replacement]/g replace without confirmation
:%s/[pattern]/[replacement]/gc replace with confirmation
TABS
gt go to next tab
gT go to prev tab
:tabs list tabs
:tabedit file open file in tab
:tabclose
BUFFERS
:ls list buffers
:bp prev buffer
:bn next buffer
:bd close buffer
:new new window & buffer
:e filename edit file
SPLITS
:sp split window
:vsp vertically split window
C-w j go to split above
C-w k go to split below
C-w h go to split left
C-w l go to split right
:q close split
FOLDING
zo open fold
zc close fold
KEY NOTATION
http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_%28Part_2%29
https://stackoverflow.com/questions/1764263/what-is-the-leader-in-a-vimrc-file
KEY MAPS
http://michael.peopleofhonoronly.com/vim/vim_cheat_sheet_for_programmers_print.png
https://external-preview.redd.it/iigrixvxp5aYN9ox7Gr1dfI_rhLRotWlLsCafjJqjEQ.png?auto=webp&s=1594ddc17408cb9186a73c2a6d1a1bf1e00769dd
LINKS
http://vim.wikia.com/wiki/Buffers
http://vim.wikia.com/wiki/Folding
http://vim.wikia.com/wiki/Shifting_blocks_visually
https://www.keycdn.com/blog/vim-commands
https://medium.com/@danidiaz/configuring-ideavimrc-de16a4da0715
https://stackoverflow.com/questions/1764263/what-is-the-leader-in-a-vimrc-file
https://guide.freecodecamp.org/vim/useful-commands/
REACT DEV
https://drivy.engineering/setting-up-vim-for-react/
https://github.com/tpope/vim-vinegar
https://github.com/mjackson/dotfiles/blob/master/vimrc
https://engagor.github.io/blog/2017/02/15/vim-ide-exploring-code/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment