Sei sulla pagina 1di 2

Vim Cheat Sheet

Global Editing Cut and paste Working with multiple files Tabs
:help keyword - open help r - replace a single character yy - yank (copy) a line :e file - edit a file in a new :tabnew or :tabnew file
for keyword buffer - open a file in a new tab
J - join line below to the current 2yy - yank (copy) 2 lines
:o file - open file one :bnext or :bn - go to the Ctrl + wT - move the current
yw - yank (copy) the characters next buffer split window into its own tab
:saveas file - save file as cc - change (replace) entire line of the word from the cursor
position to the start of the next :bprev or :bp - go to the gt or :tabnext or :tabn -
:close - close current pane cw - change (replace) to the end word previous buffer move to the next tab
of the word
K - open man page for word y$ - yank (copy) to end of line :bd - delete a buffer (close a gT or :tabprev or :tabp -
under the cursor c$ - change (replace) to the end file) move to the previous tab
of the line p - put (paste) the clipboard
Cursor movement after cursor :ls - list all open buffers #gt - move to tab number #
s - delete character and
h - move cursor left substitute text P - put (paste) before cursor :sp file - open a file in a :tabmove # - move current
new buffer and split window tab to the #th position (indexed
j - move cursor down S - delete line and substitute text dd - delete (cut) a line from 0)
(same as cc) :vsp file - open a file in a
k - move cursor up 2dd - delete (cut) 2 lines new buffer and vertically split :tabclose or :tabc - close
xp - transpose two letters window the current tab and all its
l - move cursor right (delete and paste) dw - delete (cut) the characters windows
of the word from the cursor Ctrl + ws - split window
H - move to top of screen u - undo position to the start of the next :tabonly or :tabo - close
word Ctrl + ww - switch windows all tabs except for the current
M - move to middle of screen Ctrl + r - redo one
D - delete (cut) to the end of the Ctrl + wq - quit a window
L - move to bottom of screen . - repeat last command line :tabdo command - run the
Ctrl + wv - split window command on all tabs (e.g.
w - jump forwards to the start of d$ - delete (cut) to the end of vertically :tabdo q - closes all opened
a word Marking text (visual mode)
the line tabs)
v - start visual mode, mark Ctrl + wh - move cursor to
W - jump forwards to the start of lines, then do a command (like x - delete (cut) character the left window (vertical split)
a word (words can contain y-yank)
punctuation) Ctrl + wl - move cursor to
Exiting
V - start linewise visual mode the right window (vertical split)
e - jump forwards to the end of :w - write (save) the file, but
a word o - move to other end of marked don't exit Ctrl + wj - move cursor to
area the window below (horizontal
E - jump forwards to the end of :w !sudo tee % - write out split)
a word (words can contain Ctrl + v - start visual block the current file using sudo
punctuation) mode Ctrl + wk - move cursor to
:wq or :x or ZZ - write (save) the window above (horizontal
b - jump backwards to the start O - move to other corner of and quit split)
of a word block
:q - quit (fails if there are
B - jump backwards to the start aw - mark a word unsaved changes)
of a word (words can contain
punctuation) ab - a block with () :q! or ZQ - quit and throw
away unsaved changes
0 - jump to the start of the line aB - a block with {}
^ - jump to the first non-blank ib - inner block with () Search and replace
character of the line /pattern - search for pattern
iB - inner block with {}
$ - jump to the end of the line ?pattern - search backward
Esc - exit visual mode for pattern
g_ - jump to the last non-blank
character of the line Visual commands \vpattern - 'very magic'
pattern: non-alphanumeric
gg - go to the first line of the > - shift text right characters are interpreted as
document special regex symbols (no
< - shift text left escaping needed)
G - go to the last line of the
document y - yank (copy) marked text n - repeat search in same
direction
5G - go to line 5 d - delete marked text
~ - switch case N - repeat search in opposite
fx - jump to next occurrence of direction
character x
Registers :%s/old/new/g - replace all
tx - jump to before next old with new throughout file
occurrence of character x :reg - show registers content
"xy - yank into register x :%s/old/new/gc - replace
} - jump to next paragraph (or all old with new throughout file
function/block, when editing "xp - paste contents of register with confirmations
code) x
:noh - remove highlighting of
{ - jump to previous paragraph search matches
(or function/block, when editing Marks
code) :marks - list of marks Search in multiple files
zz - center cursor on screen ma - set current position for :vimgrep /pattern/
mark A {file} - search for pattern in
Ctrl + b - move back one full multiple files
screen `a - jump to position of mark A
Ctrl + f - move forward one y`a - yank text to position of :cn - jump to the next match
full screen mark A
:cp - jump to the previous
Ctrl + d - move forward 1/2 a match
screen Macros
qa - record macro a :copen - open a window
Ctrl + u - move back 1/2 a containing the list of matches
screen q - stop recording macro
@a - run macro a
Insert mode -
Insert mode -
inserting/appending text @@ - rerun last run macro
i - insert before the cursor
I - insert at the beginning of the
line

a - insert (append) after the


cursor

A - insert (append) at the end of


the line

o - append (open) a new line


below the current line

O - append (open) a new line


above the current line

ea - insert (append) at the end


of the word

Esc - exit insert mode

Potrebbero piacerti anche