# Vim the Six Billion Dollar editor

Better, Stronger, Faster.

Learn vim and it will be your last text editor. There isn’t any better text editor that I know of. It is hard to learn, but incredible to use.

I suggest you teach yourself Vim in 4 steps:

• 生存
• 适应
• 更好, 更强大, 更快
• 超级牛逼

• vim 需要 2 周
• 普通编辑器 3 天.

# Survive

In a standard editor, typing on the keyboard is enough to write something and see it on the screen. Not this time. Vim is in Normal mode. Let’s go to Insert mode. Type the letter i.

You should feel a bit better. You can type letters like in a standard editor. To get back to Normal mode just press the ESC key.

You now know how to switch between Insert and Normal mode. And now, here are the commands that you need in order to survive in Normal mode:

## Mode switch

• i → Insert mode. Type ESC to return to Normal mode.
• x → Delete the char under the cursor
• :wq → Save and Quit (:w save, :q quit)
• dd → Delete (and copy) the current line
• p → Paste
• hjkl (highly recommended but not mandatory) → basic cursor move (←↓↑→).
• Hint: j looks like a down arrow.
• :help → Show help about . You can use :help without a to get general help.

## Insert mode variations:

• a → insert after the cursor
• o → insert a new line after the current one
• O → insert a new line before the current one
• cw → replace from the cursor to the end of the word

## Basic moves

• 0 → go to the first column
• ^ → go to the first non-blank character of the line
• \$ → go to the end of line
• g_ → go to the last non-blank character of line
• /pattern → search for pattern

## Copy/Paste

• P → paste before, remember p is paste after current position.
• yy → copy the current line, easier but equivalent to ddP

## Undo/Redo

• u → undo
• → redo

• :e <path/to/file> → open
• :w → save
• :saveas <path/to/file> → save to <path/to/file>
• :x, ZZ or :wq → save and quit (:x only save if necessary)
• :q! → quit without saving, also: :qa! to quit even if there are modified

## hidden buffers.

:bn (resp. :bp) → show next (resp. previous) file (buffer)