Skip to content

Instantly share code, notes, and snippets.

@athieriot
Last active December 29, 2015 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save athieriot/0ae7aeedf01b5bfbef0d to your computer and use it in GitHub Desktop.
Save athieriot/0ae7aeedf01b5bfbef0d to your computer and use it in GitHub Desktop.
Vim
--------------------------------
BASICS
--------------------------------
i / insert
u / Undo
<ctrl-r> / Redo
:q / quit
:q! / force
:wq / save and quit
<ESC> Escape insert mode
--------------------------------
NAVIGATE
--------------------------------
hjkl or arrows / moving around
w / next word
b / previous word
} / next paragraph
{ / previous
:3 / move to line 3
gg / beginning of file
G / end of file
0 / beginning of line
$ / end of line
% / corresponding parenthesis
--------------------------------
EDIT
--------------------------------
i / Insert before
a / Insert after
I / Insert beginning line
A / Insert end line
o / Insert bellow
O / Insert above
r / replace
cw / change word
c} / Change paragraph
x / cut character
dd / cut line
dw / cut word
y / copy (yank) character
yy / copy line
3y / copy 3 lines
yw / copy word
p / paste
<ctrl-a> / Increase a number
<ctrl-x> / Decrease a number
. / Repeat last change
--------------------------------
SEARCH
--------------------------------
/<text> / Search a text
/ / Search previous text
# / Search the selected word
n / next find
N / previous find
:noh / hide highlight
--------------------------------
VISUAL
--------------------------------
v select characters
<shift-v> select line
<ctrl-v> select columns
y / yank selection
:s/// sed on selection
--------------------------------
REGISTER ('+' needs vim-gnome or macvim)
--------------------------------
"+y / yank to register +
"+p / paste from register +
:registers
--------------------------------
FOLDING
--------------------------------
Select a few lines:
zf / fold
za / unfold
--------------------------------
FILES
--------------------------------
vim one.txt two.txt
:edit pom.xml / open a file (Autocomplete)
:new / create a file
:ls / list open files (:buffers)
:n / To next file
:p / To previous file
:b4 / To file 4
:b <tab> / autocomplete files
--------------------------------
WINDOWS
--------------------------------
:help
:split
:vsplit
<ctrl+w> hjkl / arrows / move cursor
<ctrl+w> + / - / resize horizontally split windows
<ctrl+w> < / > / resize vertically split windows
<ctrl+w> = / resize equally all windows
<leader><leader> / maximize current window (See plugin section)
<ctrl+w> HJKL / r / move windows
<ctrl+w> c / close a window
--------------------------------
TABS
--------------------------------
:tabnew
:tabclose
:tabn / next
:tabp / previous
:tabm / move a tab
--------------------------------
MARKS
--------------------------------
ma / add mark a
dma / remove mark a
'a / Jump to mark a
:marks / list all marks
--------------------------------
MACRO RECORD
--------------------------------
qa / Start recording in register a
q / stop recording
@a / Play macro from register a
3@a / Play 3 times
--------------------------------
EXTRA
--------------------------------
:set list
:set nolist
:set number
:set nonumber
= / Formatting
:! / Execute a command without exiting vim
:w !sudo tee % > /dev/null / Write as root
--------------------------------
CONFIGURATIO / PLUGINSN
--------------------------------
~/.vimrc
cmap w!! / make new shortcuts
Airline (Status bar custom)
Git Gutter (Git changes)
Solarized (Color scheme)
Surround:
- cs"' / replace " by '
- cst<br> / replace current surrounding by <br></br>
- yss) / surround the line by ( and )
- ysiw] / surround the word by [ and ]
- dst / remove surrounding
<Ctrl-n> / NerdTree
<Ctrl-p> / Search files
Supertab:
- <tab> / autocompletion
Zoomwin:
- <leader><leader> / maximize current window
Fugitive (Git integration):
- :Gblame / Display blame per line
- :Gstatus - / p / Add or Reset file and patch
- :Gcommit / Commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment