-
Windows:
Download the official installer from vim.org and follow the setup process.
Alternatively, use Chocolatey or Scoop to install Vim:- Chocolatey:
choco install vim -y - Scoop:
scoop install vim
- Chocolatey:
-
Linux:
Use your package manager:- For Ubuntu/Debian:
sudo apt install vim - For Fedora:
sudo dnf install vim - For Arch:
sudo pacman -S vim
- For Ubuntu/Debian:
-
macOS:
Install Vim via Homebrew:brew install vim
- Esc: Enter Normal mode.
- i: Enter Insert mode.
- v: Enter Visual mode.
- :: Enter Command-line mode.
:w: Save file.:q: Quit.:wq: Save and quit.:q!: Quit without saving.:e filename: Open a file.:x: Save and quit (same as:wq).
h: Left.l: Right.j: Down.k: Up.
w: Next word.b: Previous word.e: End of the current/next word.
0: Start of the line.^: First non-whitespace character.$: End of the line.
{: Beginning of the previous paragraph.}: Beginning of the next paragraph.
Ctrl + u: Half-screen up.Ctrl + d: Half-screen down.Ctrl + b: Full-screen up.Ctrl + f: Full-screen down.
gg: First line of the file.G: Last line of the file.:n: Go to linen.
i: Insert before the cursor.a: Insert after the cursor.o: Open a new line below.O: Open a new line above.
x: Delete a character.dd: Delete the current line.dw: Delete a word.d$: Delete to the end of the line.
u: Undo.Ctrl + r: Redo.
yy: Copy (yank) the current line.yw: Yank a word.p: Paste after the cursor.P: Paste before the cursor.
r<char>: Replace the current character with<char>.R: Enter Replace mode.
v: Start visual selection.V: Start line selection.Ctrl + v: Start block (column) selection.d: Delete selected text.y: Yank (copy) selected text.
/pattern: Search forpattern.n: Repeat the search forward.N: Repeat the search backward.:s/old/new: Replace the first occurrence ofoldwithnewin the current line.:s/old/new/g: Replace all occurrences in the current line.:%s/old/new/g: Replace all occurrences in the entire file.:%s/old/new/gc: Replace all with confirmation.
:split: Split horizontally.:vsplit: Split vertically.Ctrl + w w: Switch between windows.Ctrl + w q: Close the current window.Ctrl + w o: Close all other windows.
:e file: Open a file in a new buffer.:ls: List all buffers.:b n: Switch to buffern.:bd: Close the current buffer.
:set number: Show line numbers.:set relativenumber: Show relative line numbers.:syntax on: Enable syntax highlighting.:set hlsearch: Highlight search results.:set nohlsearch: Turn off search highlights.
:q: Exit help.
Enjoy editing with Vim! 😊