Skip to content

Instantly share code, notes, and snippets.

@abubaker417
Created January 19, 2026 17:00
Show Gist options
  • Select an option

  • Save abubaker417/af1285b1e62a63ef832bbaabaf3a711c to your computer and use it in GitHub Desktop.

Select an option

Save abubaker417/af1285b1e62a63ef832bbaabaf3a711c to your computer and use it in GitHub Desktop.
Vim Commands
## πŸ”Ή Vim Modes (most important concept)
- `i` β†’ Insert mode (start typing)
- `Esc` β†’ Back to Normal mode (always your safe key)
- `:` β†’ Command mode
- `v` β†’ Visual mode (select text)
------
## πŸ”Ή File Commands
- `:w` β†’ Save file
- `:q` β†’ Quit
- `:wq` β†’ Save & quit
- `:q!` β†’ Quit without saving
- `:e filename` β†’ Open another file
------
## πŸ”Ή Moving Around (Navigation)
- `h` β†’ Left
- `l` β†’ Right
- `j` β†’ Down
- `k` β†’ Up
πŸ“Œ Faster movement:
- `w` β†’ Next word
- `b` β†’ Previous word
- `0` β†’ Start of line
- `$` β†’ End of line
- `gg` β†’ Top of file
- `G` β†’ Bottom of file
- `:n` β†’ Go to line number `n` (e.g. `:25`)
------
## πŸ”Ή Editing Text
- `i` β†’ Insert before cursor
- `a` β†’ Insert after cursor
- `o` β†’ New line below
- `O` β†’ New line above
- `x` β†’ Delete character
- `dd` β†’ Delete line
- `yy` β†’ Copy (yank) line
- `p` β†’ Paste
- `u` β†’ Undo
- `Ctrl + r` β†’ Redo
------
## πŸ”Ή Visual Mode (Selection)
- `v` β†’ Select characters
- `V` β†’ Select whole line
- `Ctrl + v` β†’ Block (column) selection
- After selecting:
- `d` β†’ Delete
- `y` β†’ Copy
- `p` β†’ Paste
------
## πŸ”Ή Search & Replace
- `/word` β†’ Search forward
- `?word` β†’ Search backward
- `n` β†’ Next match
- `N` β†’ Previous match
πŸ” Replace:
```
:%s/old/new/g
```
- `%` β†’ Entire file
- `g` β†’ Replace all occurrences
------
## πŸ”Ή Useful Power Commands (Very Handy)
- `.` β†’ Repeat last command
- `>>` β†’ Indent line
- `<<` β†’ Unindent line
- `:%y+` β†’ Copy entire file
- `:set number` β†’ Show line numbers
- `:set nonumber` β†’ Hide line numbers
------
## πŸ”Ή Emergency Escape πŸ˜„
If Vim ever feels β€œstuck”:
```
Esc β†’ :q! β†’ Enter
```
------
### ⭐ If you remember ONLY 10 commands
```
i Esc :w :q :wq
dd yy p u /search
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment