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

Vim Cheat Sheet

Uploaded by

Ajay 19cse003
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)
47 views3 pages

Vim Cheat Sheet

Uploaded by

Ajay 19cse003
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

between yy yank (copy) a line :b[uffer] file - go to a buffer by file

K - open man page for word


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

A - insert (append) at the end of :vim[grep] /pattern/


Ctrl + ] - jump to the tag
the line under cursor {`{file}`} - search for
pattern in multiple files
o - append (open) a new line
below the current line
:cn[ext] - jump to the next
O - append (open) a new line match
above the current line
:cp[revious] - jump to the
ea - insert (append) at the end previous match
of the word
:cope[n] - open a window
Ctrl + h - delete the character containing the list of matches
before the cursor during insert
mode :ccl[ose] - close the quickfix
window
Ctrl + w - delete word before
the cursor during insert mode Tabs
:tabnew or :tabnew
Ctrl + j - add a line break at
the cursor position during insert {page.words.file} - open
mode a file in a new tab

Ctrl + t - indent (move right) Ctrl + wT - move the current


line one shiftwidth during insert split window into its own tab
Ct se t t e co te ts
of register x
:tabo[nly] - close all tabs
Ctrl + ox - Temporarily enter except for the current one
normal mode to issue one
normal-mode command x. :tabdo command - run the
command on all tabs (e.g. :tabdo
Esc or Ctrl + c - exit insert q - closes all opened tabs)
mode

You might also like