0% found this document useful (0 votes)
51 views

Cheatsheet - VIM

This document provides a cheat sheet for commonly used Vim commands organized into the following categories: moving around text, marks, modifying text, text objects, visual mode, searching, macros, and files. It includes brief explanations and keyboard shortcuts for commands to insert, delete, change, copy, and paste text as well as navigate, search, save files, and use registers and macros in Vim.

Uploaded by

it
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)
51 views

Cheatsheet - VIM

This document provides a cheat sheet for commonly used Vim commands organized into the following categories: moving around text, marks, modifying text, text objects, visual mode, searching, macros, and files. It includes brief explanations and keyboard shortcuts for commands to insert, delete, change, copy, and paste text as well as navigate, search, save files, and use registers and macros in Vim.

Uploaded by

it
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/ 2

Vim Cheat Sheet

by nwilde via cheatography.com/68037/cs/17135/

Moving  Marks  Modifying Text  (cont)

 k Make mark m[a-​zA-Z] Paste text after cursor p

j Paste text before cursor P


 Go to line with mark '[a-​zA-Z]
 h Go to actual column mark `[a-zA-Z] If you copy an entire line, p will paste the whole
line below the current line and P will do the
 l :marks Show marks
same above.
Move Forward One "Word" w
The marks A-Z are stored between files.
Forward to Whitespace W
the marks a-z are only in that single file. Text Objects 
Move Forward to End of "Word" e So two files can have different marks a
Same but to Whitespace E but there can only be one A mark. A word (arround something) a<motion/char>

Move Backward one word (start) b Inner word (inside something) i<motion/char>

Move Backward to whitespace B Inserting Text 


The text objects can be used with text
Page Down One Page <Ctrl-f> Insert before current position i modifying commands, like d, c, y, and p. ciw will
Insert at beginning of line (first I change the inner word (keep whites​pace) and
Page Up One Page <Ctrl-b>
char) wait for text in insert mode.
These can be used with text objects and repeat modifiers For more inform​ation see :help text-o​bjects
Insert after current position a
ie 2j will move down 2 lines instead of one, 3w will move
Insert at the end of line A
3 "​wor​ds" forward, etc.
Visual Mode 
Insert new line below current line o

Moving Advanced  Insert new line above current line O Enter Visual Mode v

Read Text from <so​urc​e> :r Enter Visual Block Mode <Ct​rl-​v>


Move to End of Line $
(source can be a file or file.txt Enter Visual Line Mode <​Shi​ft-​v>
Move to beginning of Line (first character) ^ command)
Visual mode accepts commands like d, c, y,
Move to beginning of line 0
and p after text has been selected.
Modifying Text 
Move to top of file gg

Move to bottom of file G Delete one char x Searching 


Delete one char to left X
Move to line <num> <num>G 6G Search forward /
Delete text to motion d<mo​tio​n
Find next occurrence of <char> f<char> Search backward ?
>
Find previous occurrence of <char> F<char>
Move to next search result n
Change text to motion c<mo​tio​n
'Till the next occurence of <char> t<char> Move to previous search N
'Till the previous occurrence of <char> T<char> >
Match whole word \<text\>
Move cursor to matching pair () {} [] % Delete single line dd
Regex searching ^$.
Move cursor to top of screen H (Home) Change entire line cc | S
Search forward the word under the *
Move cursor to middle of screen M Delete to end of line D
cursor
Move cursor to bottom of screen L (Last) Change to the end of line C
Search backward the word under the #
Re-pos​ition cursor to the top zt Replace single character at r<ch​ar> cursor
cursor
Re-pos​ition cursor to the middle zz Escape regex chars with \
Enter insert mode but replace R
Re-pos​ition cursor to bottom zb
text
Registers
You can repeat the commands with f and t using ; for
Copy text to motion y<m​oti​on
forward repeat and , for backwards repeat Access register "​[a-z]
>
Append to register "​[A-Z]
Copy line yy

By nwilde Published 1st November, 2018. Sponsored by Readability-Score.com


cheatography.com/nwilde/ Last updated 19th September, 2018. Measure your website readability!
Page 1 of 2. https://readability-score.com
Vim Cheat Sheet
by nwilde via cheatography.com/68037/cs/17135/

Macros 

Start recording macro q[a-z]

Execute recorded macro @[a-z]

Execute last used macro @@

Files 

Save file :w

Save and Quit :wq

Edit a new file :e filename

Save copy of file :w filename.copy

Save copy and edit copy of file :saveas filename.copy

Change name of the current file :file filename

Use ! to override warnings about saving files. Like if you type


:q without saving changes Vim will warn you about this. But if
you really want to discard your changes use :q!

Files Advanced  

Open file in a split window :split filename

Open file in a vertically split window :vsplit filename

Open file in a new tab :tabedit filename

Move to window <Ct​rl-​w><​mot​ion>

Move to next tab gt

Move to previous tab gT

Move current window to tab <Ctrl-W>T

By nwilde Published 1st November, 2018. Sponsored by Readability-Score.com


cheatography.com/nwilde/ Last updated 19th September, 2018. Measure your website readability!
Page 2 of 2. https://readability-score.com

You might also like