Code

VIM Cheat Sheet

February 21, 2023
11 min
By
Ramesh
Share

Introduction

Vim is the editor of choice for many developers and power users. It’s a “modal” text editor based on the vi editor written by Bill Joy in the 1970s for a version of UNIX. It inherits the key bindings of vi, but also adds a great deal of functionality and extensibility that are missing from the original vi.

What the heck do we mean by modal? When you’re using most word processors and text editors, the alphanumeric keys (i.e., a through z, 1 through 9) are only used to input those characters unless they’re modified by a control key. In Vim, the mode that the editor is in determines whether the alphanumeric keys will input those characters or move the cursor through the document.

For more read this introduction to vim guide

Disclaimer: This cheatsheet is summarized from personal experience and other online tutorials. It should not be considered as an official advice. You can check,
  1. vim documentation
  2. vim main help page
  3. vim wiki
  4. vim man page

Content

Global

Global keywords of vim

Command Structure

Command structure keywords in vim

Operators that needs motions or text objects or other commands

Operator keywords

Text Objects

Motions

  • Cursor Movements
Cursor movements in vim
  • Word Movements
Word Movements in vim
  • Line Movements
Line Movements in vim
  • Block Movements
Block movements in vim
  • Other Movements
Other movements in vim
  • Marker Movement
Marker Movement in Vim
  • Undo
Undo in vim
  • Characters
Characters in VIM

Python Mapping

Python Mapping in VIM
  • Example

Page Scrolls

Macro

Macro in VIM

Insert mode - inserting/appending text

Insert Mode in VIM

Editing

Editing in VIM

Cut and paste

Cut and Paste in VIM

Marking text (visual mode)

Making text in VIM

Visual commands

Visual Block mode only
Visual block mode in VIM
For all visual selections
Shifting in VIM
Search and replace
Search and replace in VIM
Search in multiple files
Search in multiple files in VIM
Exiting
Exiting in VIM
Working with multiple files
  • Commands
Commands in VIM
  • Splitting and Movements
Splitting and Movements in VIM
  • Change window size
Change window size in VIM
Tabs

Tips

Why ESC?

The Vi editor was originally written on an ADM-3A terminal, which had the Escape key positioned where the Tab key occurs on most modern keyboards.(ref)

{% img https://i.ibb.co/bJcdsdy/Wm8r5.jpg ‘“ADM-3A terminal keyboard” “ADM-3A terminal keyboard”’%}

More