:wq
Example: Use this when you have finished editing and want to write changes before closing.
Gotcha: Command mode is required. Press `Esc` first if Vim is still in insert mode.
This page is for the Vim moves people search for most often: save and quit, replace text, copy lines, and navigate quickly.
:wq
Example: Use this when you have finished editing and want to write changes before closing.
Gotcha: Command mode is required. Press `Esc` first if Vim is still in insert mode.
:q!
Example: Use this when you opened the wrong file or want to discard the current edit session.
Gotcha: This throws away unsaved edits in the current buffer.
:%s/old/new/g
Example: Use this for a whole-file replacement when the pattern is straightforward and you want a fast edit.
Gotcha: Add the `c` flag if you want confirmation for each replacement: `:%s/old/new/gc`.
yy
Example: Use this in normal mode to yank the current line into Vim's unnamed register.
Gotcha: If you are in insert mode, press `Esc` first. `2yy` copies two lines.
/pattern
Example: Type the pattern after `/`, press Enter, then use `n` and `N` to move through matches.
Gotcha: Search highlights can remain after the task. Use `:nohlsearch` to clear the visual highlight.
Vim remains relevant because it compresses navigation, editing, and repetition into a small set of composable ideas. Once the basics click, many text transformations become faster than equivalent pointer-heavy editing. This page focuses on the Vim moves people actually search for: modes, navigation, deletion, copy and paste, search, and save or quit operations.
If you came here looking for Vim documentation, a Vim cheat sheet, or the answer to “what are the basic Vim commands?”, this reference is meant to give you the productive layer first. It is not trying to replace :help. It is trying to make you useful in the editor right now.
. command is one of the biggest reasons Vim stays efficient.| Concept | Example | Why it matters |
|---|---|---|
| Normal mode | Esc |
Navigation and commands happen here |
| Insert mode | i, a, o |
Enter text |
| Visual mode | v, V, Ctrl+v |
Select text for later actions |
| Motion | w, b, 0, $, gg, G |
Move precisely without arrows |
| Operator | d, c, y |
Delete, change, yank |
| Text object | iw, ip, " |
Act on words, paragraphs, quoted text |
| Repeat | . |
Re-run the last change |
| Search | /pattern and n |
Move through matches quickly |
```vim
i " insert before cursor
A " append at end of line
dd " delete line
yy " yank line
p " paste after cursor
u " undo
Ctrl-r " redo
:w " save
:q " quit
:wq " save and quit
```
These are basic Vim commands, but they matter because they establish the core interaction style. You are not selecting from menus. You are issuing editing instructions directly. Once that feels normal, the rest of the editor becomes much easier to learn.
New Vim users often fixate on insert commands first. The bigger shift is movement. If you can jump by word, line, search match, paragraph, or file boundary without leaving the home row, editing becomes much more fluid. This is why a strong Vim reference always gives movement the same status as insert and delete commands.
For example, dw means delete a word because d is an operator and w is a motion. ci" means change inside quotes because c is the operator and i" is the text object. This composability is why Vim still feels efficient decades after its origin. The acronym stands for Vi IMproved, and the “improved” part is best felt in how commands combine.
A lot of everyday Vim work is not exotic. It is finding the next match, changing a repeated token, or fixing a pattern across a file. Search with /pattern, jump through results with n and N, and use . when the same edit should be repeated. The ability to separate find the next place from repeat the last change is one of Vim's most productive ideas.
For a file-wide replacement, use a substitution command deliberately:
```vim
:%s/old/new/g
```
Read that command as: across the whole file, substitute old with new, globally on each line. Add c at the end if you want confirmation before each change.
| Mistake | Better habit |
|---|---|
| Forgetting which mode you are in | Tap Esc, then continue deliberately |
| Using arrow keys for everything | Learn a few motions that remove hand travel |
| Memorizing isolated commands only | Practice operator + motion combinations |
| Editing repeated text manually | Use search plus . or substitution |
| Panicking at the command line | Read the command, then finish or cancel cleanly |
Vim is used for fast keyboard-first text editing, especially when navigation, repetition, and precise changes matter.
Start with i, a, dd, yy, p, u, :w, :q, /pattern, and n. Those commands cover insert, delete, copy, paste, undo, save, quit, and search.
Yes. It remains relevant anywhere keyboard-driven editing, remote environments, or efficient text transformation matter.
Vim stands for Vi IMproved, reflecting its relationship to the earlier vi editor.
Pair Vim with the VS Code shortcut reference for non-modal editor workflows, the Bash reference when editor work becomes shell automation, the Postgres reference when you edit schema files and migration scripts, or the Developer Reference Hub to move between text, data, and shell tasks.
The appeal of Vim is not nostalgia. It is the way a small command vocabulary scales with repetition. If you touch text all day, small savings in movement and editing accumulate quickly. That is why even a short reference page can be valuable: it keeps the composable parts visible until they become instinctive.
Even if you use Vim only part-time, a reference like this lowers the re-entry cost. You do not have to remember everything. You only need enough of the core language to move, change, search, repeat, and save with confidence.
That baseline matters daily.
We need above all to know about changes; no one wants or needs to be reminded 16 hours a day that his shoes are on.
…
…