The Beginner’s Vim Cheat Sheet

Click to expand the infographic.
Submitted by: 256 Kilobytes

All of the Vim commands and tricks that you actually need to know. Hotkeys, tips, and tricks for beginners of all types.

What Is Vim?

Vim is a powerful text editor that allows you to edit text using only the keyboard – no mouse required. This helps to improve efficiency, particularly for software engineers, programmers and developers.

Vim comes with an array of default shortcuts, but you can also edit/add new commands to customize it using the .vimrc file.

Vim Commands Cheat Sheet, Copy-Pasteable

Exiting Vim

  • :w  - Write (Save)
  • :wq - Write and quit
  • :q  - Quit, fails if unsaved
  • :q! - Quit, even if unsaved

Modes

  • ESC    - Return to normal mode
  • i      - Insert at cursor position
  • a      - Insert after cursor position
  • o      - Insert on line below cursor
  • v      - Enter visual mode
  • ctrl+v - Enter visual mode (vertical)
  • V      - Enter visual mode (full lines)

Toggling Case

  • u [in visual mode] - To lowercase
  • U [in visual mode] - To uppercase
  • Undo/Redo
  • u      - Undo
  • ctrl+r - Redo

Movement

  • $     - Jump to end of line
  • ^     - Jump to start of line
  • h     - Move left
  • j     - Move down
  • k     - Move up
  • l     - Move right
  • H     - Move to top of screen
  • M     - Move to middle of screen
  • L     - Move to bottom of screen
  • gg    - Move to start of file
  • G     - Move to end of file
  • 420gg - Move to line 420
  • w     - Jump to start of next word
  • b     - Jump to start of prev word

Search

  • /something    - Search for string
  • n             - Jump to next match
  • N             - Jump to prev match
  • /something\c  - Case insensitive search

Copy-Pasting

  • y  [in visual mode] - Copy highlighted text
  • yy                  - Copy the current line
  • d  [in visual mode] - Cut highlighted text
  • dd                  - Cut the current line
  • Ctrl+Shift+V        - Paste from external clipboard

Find-and-Replace

  • Find and Replace All in Document
    • :%s/find/replace/g
  • Find and Replace All on Current Line
    • :s/find/replace/g  [in visual mode]  
  • Find and Replace All in Highlighted Section
    • :'<,'>s/find/replace/g  [in visual mode] 
  • Find and Replace All in Document
    • :%s/address/replace/g

Important Regular Expression (REGEX) Characters

  • . - Any single character
  • * - Up to unlimited characters

Embed this infographic:

				
					<a href="https://infographicsite.com/wp-content/uploads/2019/05/vim-cheat-sheet.webp"><img width="1000" height="1500" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201000%201500'%3E%3C/svg%3E" alt="The Beginner&#8217;s Vim Cheat Sheet" data-lazy-src="https://infographicsite.com/wp-content/uploads/2019/05/vim-cheat-sheet.webp" /><noscript><img width="1000" height="1500" src="https://infographicsite.com/wp-content/uploads/2019/05/vim-cheat-sheet.webp" alt="The Beginner&#8217;s Vim Cheat Sheet" /></noscript></a>
				
			
Is there a problem with this infographic? Please let us know!