Skip to content

Instantly share code, notes, and snippets.

@kittolau
Last active May 10, 2016 14:53
Show Gist options
  • Save kittolau/700eaef53303329a09d4 to your computer and use it in GitHub Desktop.
Save kittolau/700eaef53303329a09d4 to your computer and use it in GitHub Desktop.
VIM
Concept:
A buffer is the in-memory text of a file.
A window is a viewport on a buffer.
A tab page is a collection of windows.
#cursor movement
w,e,b -> word movement
% -> go to matching parentheses ({[
[{, ]} -> go to ({[
*,# -> next/previous occurence of the word under cursor
gg,G,11G -> begin/end, linenumber of file
o,O -> insert before/after the current line
dd -> delete the current line
#diff
:edit file1
:diffthis
:vnew
:edit file2
:diffthis
#undo redo
u -> undo
Ctrl+r -> redo
#search
:/,n,N -> find next, previous
:noh -> no highlight
#replace
:s/a/b/g -> replace
#mode
i -> insert mode
V -> visual block mode
v -> visual mode
: -> command mode
#block comment
V -> visual block mode (select whole line)
I -> insert at left
esc
#copy and paste
d,y -> cut/copy(yank)
dd,yy -> cut/copy current line
p,P -> paste before/after cursor
#exec cmd
:!{command} -> run cmd
:r!{command} -> get the output of the linux_cmd into current vim
:sh -> start a shell
#buffer
:edit {file} -> edit the file in current window
:buffers/:ls/:files -> list buffers
:buffer {number}/:buffer! {number} -> go to buffer
:ls! -> list all hidden buffers
#tab
Ctrl-w v -> vsplit
Ctrl-w s -> split
Ctrl-w [hjkl] -> switch focus
Ctrl-w x -> exchange split
Ctrl-w _ -> maximun current split
Ctrl-w | -> maximun current vsplit
Ctrl-w = -> split equally
<C-W>+ / <C-W>- ->change split size
<C-w>> / <C-w>< -> change vsplit size
{number}<C-W>+ -> run multiple time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment