# Vim Cheatsheet for Beginners

---

## 🔹 Modes

* **Normal mode** → (default) for commands & navigation
    
* **Insert mode** → type text (`i`, `a`, `o`)
    
* **Visual mode** → select text (`v`, `V`)
    
* **Command mode** → type `:` for commands
    

---

## 🔹 File & Exit

| Action | Command |
| --- | --- |
| Save | `:w` |
| Quit | `:q` |
| Save & quit | `:wq` |
| Quit without saving | `:q!` |
| Save as… | `:w filename` |

---

## 🔹 Insert Text

| Action | Command |
| --- | --- |
| Insert before cursor | `i` |
| Insert after cursor | `a` |
| New line below | `o` |
| New line above | `O` |
| Append at end of line | `A` |

---

## 🔹 Navigation

| Action | Command |
| --- | --- |
| Left / Down / Up / Right | `h j k l` |
| Start of line | `0` |
| End of line | `$` |
| Next word | `w` |
| Previous word | `b` |
| End of word | `e` |
| Go to line N | `:N` |
| First line | `gg` |
| Last line | `G` |
| Half page down / up | `Ctrl-d` / `Ctrl-u` |

---

## 🔹 Editing

| Action | Command |
| --- | --- |
| Delete character | `x` |
| Delete word | `dw` |
| Delete to end of line | `D` |
| Delete line | `dd` |
| Copy (yank) line | `yy` |
| Paste | `p` |
| Change word (delete + insert) | `cw` |
| Replace single character | `r<char>` |
| Undo | `u` |
| Redo | `Ctrl-r` |

---

## 🔹 Visual Mode

| Action | Command |
| --- | --- |
| Start selection | `v` (char), `V` (line) |
| Copy | `y` |
| Delete | `d` |
| Indent | `>` |
| Unindent | `<` |

---

## 🔹 Search & Replace

| Action | Command |
| --- | --- |
| Search forward | `/word` then `n` (next), `N` (prev) |
| Search backward | `?word` |
| Replace (line) | `:s/old/new/g` |
| Replace (file) | `:%s/old/new/g` |
