VIM Keyboard Shortcuts Cheatsheet - Make Tech Easier (2024)

MainEscGets out of the current mode into the “command mode”. All keys are bound of commands.I“Insert mode” for inserting text. Keys behave as expected.:“Last-line mode” where Vim expects you to enter a command such as to save the document.:termOpen a terminal window.Navigation KeysHMove the cursor one character to the left.J or Ctrl + JMove the cursor down one line.K or Ctrl + PMove the cursor up one line.lMove the cursor one character to the right.0Move the cursor to the beginning of the line.$Move the cursor to the end of the line.^Move the cursor to the first non-empty character of the line.wMove forward one word (next alphanumeric word).WMove forward one word (delimited by a white space).5WMove forward five words.bMove backward one word (previous alphanumeric word).BMove backward one word (delimited by a white space).5BMove backward five words.GMove to the end of the file.GGMove to the beginning of the file.Navigate Around The Document(Jump to the previous sentence.)Jump to the next sentence.{Jumps to the previous paragraph.}Jumps to the next paragraph.[[Jumps to the previous section.]]Jumps to the next section.[]Jump to the end of the previous section.][Jump to the end of the next section.Insert Texta
(lowercase A)Insert text after the cursor.A
(uppercase A)Insert text at the end of the line.IInsert text before the cursor.o
(lowercase O)Begin a new line below the cursor.O
(uppercase A)Begin a new line above the cursor.Special Inserts:R [filename]Insert the file [filename] below the cursor.:R ![command]Execute [command] and insert its output below the cursor.Delete TextXDelete character at cursor.DWDelete a word.D0Delete to the beginning of a line.D$Delete to the end of a line.D)Delete to the end of sentence.DGGDelete to the beginning of the file.DGDelete to the end of the file.DDDelete line.3DDDelete three lines.Simple Replace TextR{text}Replace the character under the cursor with {text}.RReplace characters instead of inserting them.Copy/Paste TextYYCopy current line into storage buffer.[“x]yyCopy the current lines into register x.p
(lowercase P)Paste storage buffer after current line.P
(uppercase A)Paste storage buffer before current line.[“X]PPaste from register x after current line.[“X]PPaste from register x before current line.Text ModificationCCChange the text of the current line.CEChange the currently selected word at the current cursor point.C$Change the text from the cursor position until the end of the line.C0Change the text from the cursor position until the start of the line.G~Switch the case of the currently selected text as well as the line adjacent to it to its opposite.GuChange the case of the currently selected text as well as the line adjacent to it to lowercase.GUChange the case of the currently selected text as well as the line adjacent to it to uppercase.Context-Specific ModificationCIWChange the currently selected word regardless of cursor position.CIPChange the currently selected paragraph or code block regardless of cursor position.CI<Change the content of a code block enclosed in angle brackets (<>).CI{Change the content of a code block enclosed in curly brackets ({}).DIWDelete the currently selected word regardless of cursor position.DIPDelete the currently selected paragraph or code block regardless of cursor position.DAWDelete the currently selected word as well as the spaces before and after it.DI<Delete the content of a code block enclosed in angle brackets (<>).DI{Delete the content of a code block enclosed in curly brackets ({}).YIWCopy the currently selected word regardless of cursor position.YIPCopy the currently selected paragraph or code block regardless of cursor position.YAWCopy the currently selected word as well as the spaces before and after it.YI<Copy the content of a code block enclosed in angle brackets (<>).YI{Copy the content of a code block enclosed in curly brackets ({}).Undo/Redo OperationUUndo the last operation.Ctrl + RRedo the last undo.:earlier 1mGo back 1 minute in the history of the document.:later 1mGo forward 1 minute in the history of the document.Search and Replace Keys/search_textSearch document for search_text going forward.?search_textSearch document for search_text going backward.n
(lowercase n)Move to the next instance of the result from the search.N
(uppercase A)Move to the previous instance of the result.:%s/original/replacementSearch for the first occurrence of the string “original” and replace it with “replacement”.:%s/original/replacement/gSearch and replace all occurrences of the string “original” with “replacement”.:%s/original/replacement/gcSearch for all occurrences of the string “original” but ask for confirmation before replacing them with “replacement”.FSearch for the next occurrence of a character or go to the previous occurrence.BookmarksM {a-z A-Z}Set bookmark {a-z A-Z} at the current cursor position.:marksList all bookmarks.`{a-z A-Z}Jumps to the bookmark {a-z A-Z}.Select Textv
(lowercase V)Enter visual mode per character.V
(uppercase A)Enter visual mode per line.EscExit visual mode.Modify Selected Text~Switch case.DDelete a word.CChange a word.YYank (copy) a word.>Shift right.<Shift left.!Filter through an external command.Text Indentation>>Shift the currently selected line one Tab length to the right.<<Shift the currently selected line one Tab length to the left.gg=GShift the current buffer by one Tab length.>%Shift the currently selected code block to the right.<%Shift the currently selected code block to the left.>IBShift the contents of the currently selected block to the right.<IBShift the contents of the currently selected block to the left.>ATShift the contents of a block that is enclosed in angle brackets (<>) to the right.<ATShift the contents of a block that is enclosed in angle brackets (<>) to the left.MacrosQ[character]Record a Vim macro that is accessible under the [character] key.QStop a Vim macro recording.@[character]Execute a recorded Vim macro that was saved under the [character] key.@@Execute the last Vim macro that was run.Search and Execute:G/[pattern]/[vim command]Run the [vim command] in the current line for every instance of the [pattern].:G!/[pattern]/[vim command]Run the [vim command] in the current line for every instance that is not the [pattern].:%G/[pattern]/[vim command]Run the [vim command] on the entire document for every instance of the [pattern]. :%G!/[pattern]/[vim command]Run the [vim command] on the entire document for every instance that is not the [pattern]. Tab Manipulation:TABE [file path]Open the [file path] in a separate tab in the current buffer.:TABNSwitch to the next active tab in the buffer.:TABPSwitch to the previous active tab in the buffer.:TABCClose the currently active tab in the buffer.:TABOClose all inactive tabs in the buffer.Buffer Manipulation:SP [file path]Open the [file path] as a horizontally split buffer.:VSP [file path]Open the [file path] as a vertically split buffer.:LSShow a list of all the buffers currently open in Vim.:BNDisplay the contents of the next open buffer in the buffer list.:BPDisplay the contents of the previous open buffer in the buffer list.Ctrl + W, then SSplit the current window horizontally, displaying the currently active buffer in both windows.Ctrl + W, then VSplit the current window vertically, displaying the currently active buffer in both windows.Ctrl + W, then WSwitch focus between the split buffers.Ctrl + W, then XSwap the position of the currently focused buffer with an inactive one.Ctrl + W, then QDelete the currently selected buffer.Save and Quit:QQuits Vim but fails when file has been changed.:WSave the file.:W new_nameSave the file with the new_name filename.:WQSave the file and quit Vim.:Q!Quit Vim without saving the changes to the file.ZZWrite file, if modified, and quit Vim.ZQSame as :q! Quits Vim without writing changes.:sav file
:saveas file Save file as.:clo
:closeClose the current pane.
VIM Keyboard Shortcuts Cheatsheet - Make Tech Easier (2024)

FAQs

What is the fastest way to learn keyboard shortcuts? ›

The best way to quickly learn keyboard shortcuts for a new program is to practice and memorize them. You can start by using the most common and frequently used ones, such as saving, copying, pasting, undoing, and switching windows.

Which keys can be used to correct the text in Vim? ›

Basic text manipulation
  • Cut and paste. x. delete character under the cursor. X. ...
  • Select and copy. v. switch to visual mode. V. ...
  • Undo and redo. Now is a good time to tell you how to undo and redo your changes: u. undo. ...
  • Hard line wrapping. In visual mode, you can re-apply hard line wrapping to the selected lines of a paragraph by: V.

What does Q do in Vim? ›

This command tells Vim to quit, and the exclamation mark tells Vim to force quit, discarding any changes you made to the file. Here are the steps to follow: Press the Esc key to switch to command mode. Type :q! and press Enter .

What is control R in Vim? ›

Redo Changes in Vim / Vi

Any character typed in normal mode will be interpreted as a vim command. Press CTRL+r to redo the last change (entry).

What is the Ctrl D equivalent in Vim? ›

Best Vim alternative to VSCode's Ctrl+D
  1. Select first occurrence of "id_ with Shift + → x4.
  2. Select (and create a cursor on) every occurrence of the remaining N-1 "id_ with Ctrl + d x(N-1)
  3. Select the id string(s) following "id_ with → , ← (to deselect), Ctrl + Shift + →
Dec 24, 2020

What is control M in Vim? ›

In Linux, Vim anticipates Unix format line endings when opening text files. However, files edited in Windows typically contain CR+LF line endings. When Vim opens such files, the additional CR characters are perceived as part of the text and are displayed as the ^M character. This is the reason we see this character.

What is F1 f2 f3 F4 f5 f6 f7 f8 f9 f10 F11 F12? ›

The function keys or F-keys on a computer keyboard, labeled F1 through F12, are keys that have a special function defined by the operating system, or by a currently running program.

What are the 20 shortcut keys? ›

  • Copy: Ctrl + C.
  • Cut: Ctrl + X.
  • Paste: Ctrl + V.
  • Maximize Window: F11 or Windows logo key + Up arrow.
  • Open Task View: Windows logo key + Tab.
  • Display and hide the desktop: Windows logo key + D.
  • Switch between open apps: Alt + Tab.
  • Open the Quick Link menu: Windows logo key + X.

What is the coolest keyboard shortcut? ›

Best Windows Shortcuts on Your Keyboard
  • Ctrl+O: Open a new file.
  • Ctrl+P: Open the print dialog box.
  • Ctrl+F: Open the search tool to find something on the page.
  • Ctrl+R: Refresh the contents on the screen. ( ...
  • Alt+F4: Close the active program.
  • F11: Enter full-screen mode.
  • Esc: Stop or close a prompt or process.
Jan 22, 2024

What is the G command in Vim? ›

When running the g command, Vim makes two scans across the file. On the first run, it scans each line and marks the line that matches the /console/ pattern. Once all the matching lines are marked, it goes for the second time and executes the d command on the marked lines.

Which key is leader in Vim? ›

The default leader key is a backslash \ , but it's not the most comfortable binding. There are a few alternative keys that are popular in the community, with the comma ( , )being the most popular.

What is shift G in Vi? ›

Go To End of File in Vim / Vi
  1. G (shift + g) goes to the end of the file.
  2. Specifically, G (shift + g) goes to the beginning of the last line of the file in both Normal and Visual mode. ...
  3. Use dG in Normal mode.
  4. Use cG in Normal mode.
  5. Enter visual mode with v then navigate to the beginning of the last line with G.

What can I use instead of Ctrl V in Vim? ›

From the VIM documentation: Since CTRL V is used to paste, you can't use it to start a blockwise Visual selection. You can use CTRL Q instead. You can also use CTRL Q in Insert mode and Command-line mode to get the old meaning of CTRL V .

What are the arrow keys in Vim called? ›

Yes it is because in vim h j k l are the replacement of the arrow keys. Originally this was the case because Bill Joy wrote vim in a terminal where the arrow keys were on h, j, k and l. This still has the advantage that you always keep your hands on the home row.

What are the default leader shortcuts in Vim? ›

The default <leader> key is a backslash \ . To change the leader key to the comma , add let mapleader = “," to your vimrc (to use the space key add let mapleader = " “). Reload vim and test your new <leader> key.

Top Articles
Latest Posts
Article information

Author: Cheryll Lueilwitz

Last Updated:

Views: 5797

Rating: 4.3 / 5 (54 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Cheryll Lueilwitz

Birthday: 1997-12-23

Address: 4653 O'Kon Hill, Lake Juanstad, AR 65469

Phone: +494124489301

Job: Marketing Representative

Hobby: Reading, Ice skating, Foraging, BASE jumping, Hiking, Skateboarding, Kayaking

Introduction: My name is Cheryll Lueilwitz, I am a sparkling, clean, super, lucky, joyous, outstanding, lucky person who loves writing and wants to share my knowledge and understanding with you.