Skip to content Opens in a new tab
Technology

Vim Cheat Sheet for Beginners, the Commands You Need First

Infographic by August R. Garcia, 256 Kilobytes

The Unofficial Beginner's Vim Cheat Sheet by 256 Kilobytes, white text on a dark terminal background listing Vim commands for exiting, movement, modes, toggling case, undo and redo, search, copy and paste, and find and replace, with the Vim logo
Infographic by August R. Garcia, 256 Kilobytes. View the original.

A Vim cheat sheet for beginners needs only a few dozen commands. Press ESC for normal mode, i to type, :wq to save and quit and :q! to quit without saving. Move with h, j, k and l, copy with yy, cut with dd, paste with p, undo with u, search with / and replace across the file with :%s/find/replace/g.

Why Vim feels hard at first

Vim, short for Vi IMproved, is a free and open source text editor based on the older vi editor. Bram Moolenaar wrote it, and its first public release was version 1.14 in November 1991 [6]. It is installed on most Linux and macOS systems and is often the editor that opens when you run a command such as git commit on a server, which is how many people meet it for the first time.

What trips up beginners is that Vim is a modal editor. In normal mode, the mode Vim starts in, the letters on your keyboard are commands rather than text: j moves the cursor down, dd deletes a line and u undoes. You only type text in insert mode, and you select text in visual mode [6]. Most “Vim ate my file” moments come from typing in the wrong mode. If anything goes wrong, press ESC to get back to normal mode and start again.

The cheat sheet by 256 Kilobytes above [7] covers the commands most people need in their first week. The sections below explain them in the order you will use them, with a few corrections where the sheet is loose.

How to exit Vim

Exiting is the most searched Vim question for a reason. Press ESC first, then type one of these and press Enter [1]:

Command What it does
:w Write (save) the file
:wq Save and quit
😡 or ZZ Save and quit, but only write if something changed
:q Quit, which fails if there are unsaved changes
:q! or ZQ Quit and throw away unsaved changes

Commands starting with a colon are typed at the bottom of the screen, so you will see them appear there as you type.

Moving around a file

In normal mode the home row keys move the cursor: h left, j down, k up and l right. The arrow keys also work, but the point of h, j, k and l is that your hands never leave the keyboard. Larger moves have their own keys [1]:

  • w jumps to the start of the next word and b to the start of the previous word.
  • ^ jumps to the first character of the line and $ to the end of the line.
  • H, M and L move to the top, middle and bottom of the screen.
  • gg goes to the first line of the file and G to the last line.
  • A number before gg or G goes to that line, so 420gg (or 420G) jumps to line 420 [1].

Most movement commands take a count in the same way. 5j moves down five lines and 3w jumps forward three words.

Switching between Vim’s modes

These keys take you out of normal mode, and ESC always brings you back [1]:

  • i inserts text at the cursor and a inserts after it.
  • o opens a new line below the cursor and puts you in insert mode (O opens one above).
  • v starts visual mode for selecting characters, V selects whole lines and Ctrl+v selects a rectangular block, which is handy for editing columns [3].

Once you have text selected in visual mode, u makes it lowercase and U makes it uppercase [1].

Copy, cut and paste in Vim

Vim calls copying “yanking”. yy copies the current line and dd cuts (deletes) it. In visual mode, y copies the selection and d cuts it. p pastes after the cursor and P pastes before it [1]. x deletes the character under the cursor, and . repeats your last change, which saves a lot of typing [1].

The sheet’s last copy and paste line, Ctrl+Shift+V, is not a Vim command. It is the paste shortcut of many terminal windows, which pastes text as if you had typed it. Inside Vim, the system clipboard is reached through the “+ register: “+y copies to it and “+p pastes from it, on Vim builds with clipboard support [5]. Pasting with the terminal shortcut while in insert mode can mess up indentation in code, which is another reason to use the register.

Undo and redo

u undoes the last change and Ctrl+r redoes it [1]. Vim keeps a full undo history, so you can press u repeatedly to step back. Note that u means undo in normal mode and lowercase only when text is selected in visual mode.

Search and find and replace

Type / followed by a word and press Enter to search forward through the file. n jumps to the next match and N to the previous one. Adding \c anywhere in the pattern makes the search ignore case, so /something\c finds Something and SOMETHING too [4].

Find and replace uses the :s (substitute) command [2]:

Command What it does
:s/find/replace/g Replace every match on the current line
:%s/find/replace/g Replace every match in the whole file
:'<,’>s/find/replace/g Replace every match in the lines you selected
:%s/find/replace/gc Replace in the whole file, asking before each change

Without a range, :s works on the current line only, and % is the range for the entire file [1][2]. The g at the end means every match on each line rather than just the first. The sheet labels the current-line version “in visual mode”, but in visual mode, pressing : fills in ‘<,’> for you, so the command acts on the whole selection rather than one line [3]. It also prints the whole-file command twice, the second time with “address” as the example word.

Two regular expression characters worth knowing

Search and substitute patterns are regular expressions. A dot matches any single character. An asterisk means zero or more of the item before it, so it does not match anything on its own: .* is the pattern for “any run of characters” [4]. That is more precise than the sheet’s “up to unlimited characters”. To search for a literal dot or asterisk, put a backslash in front of it.

How to get better at Vim quickly

Learn a handful of commands at a time rather than memorising a full reference. Moving with h, j, k and l, saving and quitting, i and ESC, dd, yy, p and u are enough to edit files on day one. Vim also ships with a built-in 30 minute lesson: run vimtutor in a terminal. Inside Vim, :help followed by any command, such as :help :s, opens the official documentation for it [1].

Questions about Vim commands

How do you exit Vim?

Press ESC to get back to normal mode, then type :q and press Enter. If there are unsaved changes, use :wq to save and quit or :q! to quit without saving [1].

How do you save in Vim?

Type :w in normal mode and press Enter. :wq saves and exits, and 😡 saves and exits only if the file has changed [1].

How do you paste in Vim?

Copy with yy or y and paste with p (after the cursor) or P (before it). To paste from the system clipboard, use “+p on a Vim with clipboard support [5], or the paste shortcut of your terminal window.

How do you delete a line in Vim?

Put the cursor on the line in normal mode and press dd. 3dd deletes three lines. The deleted text is kept, so you can paste it elsewhere with p [1].

What is the difference between Vi and Vim?

Vim is an improved version of vi with extras such as multi-level undo, syntax highlighting, visual mode and plugins. It can run in a terminal or as a graphical program called gvim [6].

Sources

  1. Vim help, quickref.txt (quick reference guide).
  2. Vim help, change.txt (the :substitute command).
  3. Vim help, visual.txt (Visual mode).
  4. Vim help, pattern.txt (patterns and search commands).
  5. Vim help, gui_x11.txt (the “* and “+ clipboard registers).
  6. Wikipedia, Vim (text editor).
  7. 256 Kilobytes, [Infographic] The Beginner’s Vim Cheat Sheet, by August R. Garcia (2019, Internet Archive copy), the original cheat sheet.

Last reviewed 2 November 2026

Embed this infographic

Use this code only if the creator has permitted your intended use. Providing embed code does not grant a licence. Keep the creator credit and the link to the text version and sources. How you can use these infographics.

Made this infographic, or spotted a mistake? Tell us and we will put it right.

About this page

You can rely on this page: reviewed 2 November 2026, with the figures checked against their sources and every source listed.

How we review infographics
Creator

August R. Garcia, 256 Kilobytes

1 infographic on Infographic Website

See all by this creator
Topic

Technology

More in this topic
For creators

Get your infographic listed

A permanent page like this one for your graphic, with your name and a link to your site. $29, paid once.

Submit an infographic

Made an infographic?

Give it a permanent page where people looking for your subject find it, with your name and a link to your site. Content marketers, agencies, designers and researchers all list here.