Vous êtes sur la page 1sur 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 :tabnew or :tabnew
for keyword new buffer file - open a file in a new
J - join line below to the 2yy - yank (copy) 2 lines tab
:o file - open file current one :bnext or :bn - go to the
yw - yank (copy) the next buffer Ctrl + wT - move the
:saveas file - save file as cc - change (replace) entire characters of the word from current split window into its
line the cursor position to the :bprev or :bp - go to the own tab
:close - close current pane start of the next word previous buffer
cw - change (replace) to the gt or :tabnext or :tabn -
K - open man page for word end of the word y$ - yank (copy) to end of :bd - delete a buffer (close a move to the next tab
under the cursor line file)
c$ - change (replace) to the gT or :tabprev or :tabp -
Cursor movement end of the line p - put (paste) the clipboard :ls - list all open buffers move to the previous tab
after cursor
h - move cursor left s - delete character and :sp file - open a file in a #gt - move to tab number #
substitute text P - put (paste) before cursor new buffer and split window
j - move cursor down :tabmove # - move current
S - delete line and substitute dd - delete (cut) a line :vsp file - open a file in a tab to the #th position
k - move cursor up text (same as cc) new buffer and vertically (indexed from 0)
2dd - delete (cut) 2 lines split window
l - move cursor right xp - transpose two letters :tabclose or :tabc -
(delete and paste) dw - delete (cut) the Ctrl + ws - split window close the current tab and all
H - move to top of screen characters of the word from its windows
u - undo the cursor position to the Ctrl + ww - switch windows
M - move to middle of screen start of the next word :tabonly or :tabo - close
Ctrl + r - redo Ctrl + wq - quit a window all tabs except for the
L - move to bottom of screen D - delete (cut) to the end of current one
. - repeat last command the line Ctrl + wv - split window
w - jump forwards to the start vertically
of a word :tabdo command - run the
Marking text (visual mode) d$ - delete (cut) to the end of command on all tabs (e.g.
the line Ctrl + wh - move cursor to
W - jump forwards to the start v - start visual mode, mark the left window (vertical
:tabdo q - closes all
of a word (words can contain lines, then do a command opened tabs)
x - delete (cut) character split)
punctuation) (like y-yank)
Ctrl + wl - move cursor to
e - jump forwards to the end V - start linewise visual mode Exiting the right window (vertical
of a word :w - write (save) the file, but split)
o - move to other end of don't exit
E - jump forwards to the end marked area Ctrl + wj - move cursor to
of a word (words can contain :w !sudo tee % - write the window below
punctuation) Ctrl + v - start visual block out the current file using (horizontal split)
mode sudo
b - jump backwards to the Ctrl + wk - move cursor to
start of a word O - move to other corner of :wq or :x or ZZ - write (save) the window above
block and quit (horizontal split)
B - jump backwards to the
start of a word (words can aw - mark a word :q - quit (fails if there are
contain punctuation) unsaved changes)
ab - a block with ()
% - move to matching :q! or ZQ - quit and throw
character (default supported aB - a block with {} away unsaved changes
pairs: '()', '{}', '[]' - use :h
matchpairs in vim for more ib - inner block with ()
Search and replace
info)
iB - inner block with {} /pattern - search for
0 - jump to the start of the pattern
line Esc - exit visual mode
?pattern - search backward
^ - jump to the first non- Visual commands for pattern
blank character of the line > - shift text right \vpattern - 'very magic'
$ - jump to the end of the line < - shift text left pattern: non-alphanumeric
characters are interpreted as
g_ - jump to the last non- y - yank (copy) marked text
special regex symbols (no
blank character of the line escaping needed)

gg - go to the first line of the d - delete marked text n - repeat search in same
document direction
~ - switch case
G - go to the last line of the N - repeat search in opposite
document Registers direction
:reg - show registers
5G - go to line 5 content :%s/old/new/g - replace
all old with new throughout
fx - jump to next occurrence "xy - yank into register x file
of character x
"xp - paste contents of :%s/old/new/gc - replace
tx - jump to before next register x all old with new throughout
occurrence of character x file with confirmations

} - jump to next paragraph Marks :noh - remove highlighting


(or function/block, when :marks - list of marks of search matches
editing code)
ma - set current position for Search in multiple files
{ - jump to previous mark A
paragraph (or :vimgrep /pattern/
function/block, when editing `a - jump to position of mark {file} - search for pattern
code) A in multiple files

zz - center cursor on screen y`a - yank text to position of


mark A :cn - jump to the next match
Ctrl + b - move back one
full screen :cp - jump to the previous
Macros match
Ctrl + f - move forward one qa - record macro a
full screen
Ctrl + d - move forward 1/2 q - stop recording macro :copen - open a window
a screen containing the list of matches
@a - run macro a
Ctrl + u - move back 1/2 a
screen @@ - rerun last run macro

Insert mode -
inserting/appending text
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

Vous aimerez peut-être aussi