Essentials Vim Cheatsheet that You will ever need
|
| vim code editor alternate logo |
Here are some Vim cheat sheet including your requests (set nu, set tabstop, etc.) formatted as a table view for quick reference.
Vim Common Settings
|
Command |
Description |
|
:set nu |
Show line numbers |
|
:set tabstop=4 |
Set number of spaces per tab (display width) |
|
:set shiftwidth=4 |
Indentation width for >> and << |
|
:set expandtab |
Convert tabs to spaces |
|
:set noexpandtab |
Keep real tab characters |
|
:set autoindent |
Copy indent from previous line |
|
:set smartindent |
Smart indentation for code |
|
:set syntax=on |
Enable syntax highlighting |
|
:set number relativenumber |
Show both absolute and relative numbers |
|
:set cursorline |
Highlight current line |
|
:set background=dark |
Optimize colors for dark background |
syntax on filetype plugin indent on set termguicolors set t_Co=256 set background=dark colorscheme desert
To set the settings permanently just save inside $VIM/.vimrc or in Windows $VIM/_vimrc (without the colon symbol at beginning)
Vim Navigation
|
Keys |
Action |
|
w / b |
Next / previous word |
|
gg / G |
Go to start / end of file |
|
0 / $ |
Start / end of line |
|
:n |
Go to line number n (e.g., :10) |
Editing
|
Keys |
Action |
|
o / O |
New line below / above |
|
x |
Delete character |
|
dd / yy / p |
Delete / yank (copy) / paste line |
|
u / Ctrl + r |
Undo / redo |
|
r<char> |
Replace character |
|
cw / dw |
Change word / delete word |
Search and Replace
|
Command |
Description |
|
/text |
Search forward for "text" |
|
?text |
Search backward for "text" |
|
n / N |
Repeat search (next / previous) |
|
:%s/foo/bar/g |
Replace all “foo” with “bar” |
|
:s/foo/bar/g |
Replace on current line |
File Operations
|
Command |
Description |
|
:w |
Save file |
|
:q |
Quit |
|
:wq |
Save and quit |
|
:q! |
Quit without saving |
|
:e filename |
Open file |
|
:vs filename |
Vertical split open file |
|
:sp filename |
Horizontal split open file |
Split & Tab Management
|
Command |
Description |
|
:sp / :vsp |
Split window (horizontal / vertical) |
|
Ctrl + w + w |
Switch between splits |
|
:tabnew file |
Open file in new tab |
|
gt / gT |
Next / previous tab |
|
:close |
Close current split |
• Vim is a highly configurable, modal text editor used for efficient text editing
• Modes include Normal (default), Insert (typing), Visual (selection), and Command (colon commands)
• Normal Mode is used for navigation and manipulation (e.g., dd, yy, p)
• Insert Mode is entered with i, a, o to insert text
• Visual Mode allows selecting text with v, V, or Ctrl+v
• Command Mode is accessed with : to run commands like :w, :q, :e
• Highly customizable via vimrc file to set behavior and preferences
• Supports plugins to extend features like autocompletion, syntax checking, and themes
• Lightweight and fast, ideal for remote development and scripting
• Available on most systems, including Unix, Linux, Windows, and macOS
• Great for coding, system administration, and general text editing tasks
