Vim is a highly configurable text editor that can be used to efficiently edit plain text files, code, and markup. It was originally created as an extended version of the vi editor and has become popular due to its powerful editing features, including the ability to manipulate large amounts of text quickly and easily.
The Vim cheat sheet presented below provides an extensive list of commands that can be used to navigate and edit text in Vim. The commands are organized in a table format, making it easy to find the one you need. Some of the most common commands include saving files, searching for text, copying and pasting text, and undoing changes.
It’s important to note that Vim has a steep learning curve and can be difficult to use for beginners. However, with practice and patience, Vim can become a very efficient and powerful tool for editing text. The cheat sheet presented above is a great resource for anyone looking to learn Vim, and it’s a good idea to keep it handy until the commands become second nature.
In conclusion, Vim is a powerful text editor that can be used to efficiently edit text files. While it may take some time to learn, the Vim cheat sheet provided above can help make the process easier. With practice and patience, Vim can become an essential tool in any developer or writer’s arsenal.
Cheat Sheet
Command | Description |
:w | Save current file |
:wq | Save and quit |
:q | Quit |
:q! | Quit without saving |
:e | Open a file for editing |
:sp filename | Split the screen horizontally and open the specified file |
:vsp filename | Split the screen vertically and open the specified file |
:set number | Show line numbers |
:set nonumber | Hide line numbers |
:set hlsearch | Highlight search results |
:set nohlsearch | Disable search highlighting |
/pattern | Search for a pattern |
n | Jump to the next search result |
N | Jump to the previous search result |
:s/old/new/g | Replace “old” with “new” globally |
:s/old/new/ | Replace “old” with “new” in current line |
:1,$s/old/new/g | Replace “old” with “new” in the whole file |
dd | Delete current line |
yy | Copy current line |
p | Paste copied or cut text |
u | Undo |
Ctrl-R | Redo |
:w file | Save as “file” |
:r file | Insert the contents of “file” |
:set tabstop=4 | Set tab width to 4 spaces |
:set shiftwidth=4 | Set the number of spaces for indentation |
:set expandtab | Use spaces instead of tabs |
:set nowrap | Disable line wrapping |
:set wrap | Enable line wrapping |
:set mouse=a | Enable mouse support |
Ctrl-w + h | Move to the left split |
Ctrl-w + l | Move to the right split |
Ctrl-w + j | Move to the bottom split |
Ctrl-w + k | Move to the top split |
Ctrl-w + r | Rotate the splits |
Ctrl-w + x | Swap the splits |
Ctrl-w + = | Make all splits equal |
Ctrl-g | Show current file name and cursor position |
gg | Move to the first line of the file |
G | Move to the last line of the file |
:set paste | Disable auto-indentation and other features |
:set nopaste | Enable auto-indentation and other features |
:set spell | Enable spell checking |
:set nospell | Disable spell checking |
z. | Center the screen on the cursor |
Ctrl-o | Go to the previous cursor position |
Ctrl-i | Go to the next cursor position |
:noh | Remove search highlighting |
:ls | List all open buffers |
:b buffer | Switch to a different buffer |
:bp | Go to the previous buffer |
:bn | Go to the next buffer |
:bd | Close the current buffer |
:bd! | Close the current buffer without |
Reference: