0% found this document useful (0 votes)
32 views3 pages

Vim Cheat Sheet

Vim cheat sheet

Uploaded by

sunmoon09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views3 pages

Vim Cheat Sheet

Vim cheat sheet

Uploaded by

sunmoon09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Vim Cheat Sheet

Global Editing Macros Working with multiple files


:h[elp] keyword - r - replace a single qa - record macro a :e[dit] file - edit a file in a new buffer
open help for keyword character.
q - stop recording macro :bn[ext] - go to the next buffer
:sav[eas] file - save R - replace more than one
file as character, until ESC is @a - run macro a :bp[revious] - go to the previous buffer
pressed.
:clo[se] - close current @@ - rerun last run macro :bd[elete] - delete a buffer (close a file)
pane J - join line below to the
current one with one space Cut and paste :b[uffer]# - go to a buffer by index #
:ter[minal] - open a in between
terminal window yy - yank (copy) a line :b[uffer] file - go to a buffer by file
gJ - join line below to the
K - open man page for word current one without space 2yy - yank (copy) 2 lines :ls or :buffers - list all open buffers
under the cursor in between
yw - yank (copy) the :sp[lit] file - open a file in a new buffer and
Cursor movement gwip - reflow paragraph characters of the word from split window
the cursor position to the
h - move cursor left g~ - switch case up to start of the next word :vs[plit] file - open a file in a new buffer
motion and vertically split window
j - move cursor down yiw - yank (copy) word
gu - change to lowercase up under the cursor :vert[ical] ba[ll] - edit all buffers as
k - move cursor up to motion vertical windows
yaw - yank (copy) word
l - move cursor right gU - change to uppercase under the cursor and the :tab ba[ll] - edit all buffers as tabs
up to motion space after or before it
gj - move cursor down Ctrl + ws - split window
(multi-line text) cc - change (replace) entire y$ or Y - yank (copy) to end
line of line Ctrl + wv - split window vertically
gk - move cursor up (multi-
line text) c$ or C - change (replace) p - put (paste) the clipboard Ctrl + ww - switch windows
to the end of the line after cursor
H - move to top of screen Ctrl + wq - quit a window
ciw - change (replace) P - put (paste) before cursor
M - move to middle of entire word Ctrl + wx - exchange current window with next
screen gp - put (paste) the one
cw or ce - change (replace) clipboard after cursor and
L - move to bottom of to the end of the word leave cursor after the new
Ctrl + w= - make all windows equal height & width
screen text
s - delete character and Ctrl + wh - move cursor to the left window
w - jump forwards to the substitute text gP - put (paste) before (vertical split)
start of a word cursor and leave cursor
S - delete line and after the new text
W - jump forwards to the Ctrl + wl - move cursor to the right window
substitute text (same as cc) (vertical split)
start of a word (words can dd - delete (cut) a line
contain punctuation) xp - transpose two letters
2dd - delete (cut) 2 lines Ctrl + wj - move cursor to the window below
(delete and paste) (horizontal split)
e - jump forwards to the
end of a word u - undo dw - delete (cut) the Ctrl + wk - move cursor to the window above
characters of the word from
(horizontal split)
E - jump forwards to the U - restore (undo) last the cursor position to the
end of a word (words can changed line start of the next word
contain punctuation) Ctrl + wH - make current window full height at far
diw - delete (cut) word left (leftmost vertical window)
Ctrl + r - redo
b - jump backwards to the under the cursor
Ctrl + wL - make current window full height at far
start of a word . - repeat last command daw - delete (cut) word right (rightmost vertical window)
B - jump backwards to the under the cursor and the
Ctrl + wJ - make current window full width at the
start of a word (words can Marking text (visual mode) space after or before it
contain punctuation) very bottom (bottommost horizontal window)
v - start visual mode, mark
lines, then do a command d$ or D - delete (cut) to the
ge - jump backwards to the end of the line Ctrl + wK - make current window full width at the
(like y-yank) very top (topmost horizontal window)
end of a word
V - start linewise visual x - delete (cut) character
gE - jump backwards to the Diff
mode
end of a word (words can Indent text zf - manually define a fold up to motion
contain punctuation) o - move to other end of
marked area
>> - indent (move right)
line one shiftwidth zd - delete fold under the cursor
% - move to matching
character (default Ctrl + v - start visual za - toggle fold under the cursor
supported pairs: '()', '{}', '[]' - block mode
<< - de-indent (move left)
use :h matchpairs in vim line one shiftwidth
for more info)
zo - open fold under the cursor
O - move to other corner of >% - indent a block with ()
block zc - close fold under the cursor
0 - jump to the start of the or {} (cursor on brace)
line aw - mark a word >ib - indent inner block zr - reduce (open) all folds by one level
^ - jump to the first non- with ()
ab - a block with () zm - fold more (close) all folds by one level
blank character of the line
aB - a block with {} >at - indent a block with
$ - jump to the end of the <> tags zi - toggle folding functionality
line at - a block with <> tags 3== - re-indent 3 lines ]c - jump to start of next change
g_ - jump to the last non- ib - inner block with ()
blank character of the line =% - re-indent a block with [c - jump to start of previous change
() or {} (cursor on brace)
gg - go to the first line of iB - inner block with {} do or :diffg[et] - obtain (get) difference (from
the document =iB - re-indent inner block other buffer)
it - inner block with <> with {}
tags dp or :diffpu[t] - put difference (to other
G - go to the last line of the
document gg=G - re-indent entire buffer)
Esc - exit visual mode buffer
:diffthis - make current window part of diff
Vi l d
Visual commands
5gg or 5G - go to line 5 ]p - paste and adjust indent :dif[fupdate] - update differences
> - shift text right to current line
gd - move to local :diffo[ff] - switch off diff mode for current
declaration < - shift text left Exiting window
gD - move to global y - yank (copy) marked text :w - write (save) the file,
declaration but don't exit
d - delete marked text
fx - jump to next :w !sudo tee % - write
occurrence of character x ~ - switch case out the current file using
sudo
tx - jump to before next u - change marked text to
occurrence of character x lowercase :wq or :x or ZZ - write
(save) and quit
Fx - jump to the previous U - change marked text to
occurrence of character x uppercase :q - quit (fails if there are
unsaved changes)
Tx - jump to after previous Registers
occurrence of character x :q! or ZQ - quit and throw
:reg[isters] - show away unsaved changes
; - repeat previous f, t, F or registers content
T movement :wqa - write (save) and
"xy - yank into register x quit on all tabs
, - repeat previous f, t, F or
T movement, backwards "xp - paste contents of Search and replace
register x
} - jump to next paragraph /pattern - search for
"+y - yank into the system pattern
(or function/block, when
editing code) clipboard register
?pattern - search
{ - jump to previous "+p - paste from the system backward for pattern
paragraph (or clipboard register
function/block, when
\vpattern - 'very magic'
pattern: non-alphanumeric
editing code) Marks and positions characters are interpreted
:marks - list of marks as special regex symbols (no
zz - center cursor on escaping needed)
screen
ma - set current position for
mark A n - repeat search in same
Ctrl + e - move screen direction
down one line (without
moving cursor) `a - jump to position of
mark A N - repeat search in
opposite direction
Ctrl + y - move screen up
one line (without moving y`a - yank text to position
cursor) of mark A :%s/old/new/g -
replace all old with new
`0 - go to the position throughout file
Ctrl + b - move back one
full screen where Vim was previously
exited :%s/old/new/gc -
replace all old with new
Ctrl + f - move forward
one full screen `" - go to the position when throughout file with
last editing this file confirmations
Ctrl + d - move forward
1/2 a screen `. - go to the position of the :noh[lsearch] -
last change in this file remove highlighting of
search matches
Ctrl + u - move back 1/2 a
screen `` - go to the position
before the last jump Search in multiple files
Insert mode - :vim[grep]
inserting/appending text :ju[mps] - list of jumps
/pattern/
i - insert before the cursor Ctrl + i - go to newer {`{file}`} - search for
position in jump list pattern in multiple files
I - insert at the beginning
of the line Ctrl + o - go to older
position in jump list :cn[ext] - jump to the
a - insert (append) after the next match
cursor :changes - list of changes
:cp[revious] - jump to
A - insert (append) at the g, - go to newer position in the previous match
end of the line change list
:cope[n] - open a
o - append (open) a new g; - go to older position in window containing the list
line below the current line change list of matches

O - append (open) a new Ctrl + ] - jump to the tag :ccl[ose] - close the
line above the current line under cursor quickfix window

ea - insert (append) at the Tabs


end of the word
:tabnew or :tabnew
Ctrl + h - delete the {page.words.file} -
character before the cursor open a file in a new tab
during insert mode
Ctrl + wT - move the
Ctrl + w - delete word current split window into
before the cursor during its own tab
insert mode
gt or :tabn[ext] -
Ctrl + j - begin new line move to the next tab
during insert mode
gT or :tabp[revious]
Ctrl + t - indent (move - move to the previous tab
right) line one shiftwidth
during insert mode
Ctrl + d - de-indent (move #gt - move to tab number
left) line one shiftwidth #
during insert mode
:tabm[ove] # - move
Ctrl + n - insert (auto- current tab to the #th
complete) next match position (indexed from 0)
before the cursor during
insert mode :tabc[lose] - close the
current tab and all its
Ctrl + p - insert (auto- windows
complete) previous match
before the cursor during :tabo[nly] - close all
insert mode tabs except for the current
one
Ctrl + rx - insert the
contents of register x :tabdo command - run
the command on all tabs (e.g.
Ctrl + ox - Temporarily :tabdo q - closes all
enter normal mode to issue opened tabs)
one normal-mode
command x.

Esc - exit insert mode

You might also like