Skip to main content
VIM Basics Handbook

June 20, 20244 min read

If you're still reaching for the mouse to navigate text, you're doing it wrong. Vim isn't just an editor; it's a language for text manipulation. Once you speak it, every other editor feels like typing with boxing gloves on.

I remember my first run-in with Vim. Git rebase, merge conflict, panic. I ended up with a commit message that looked like a cat walked over my keyboard. Classic rookie mistake.

But here's the truth: The steep learning curve is the gatekeeper to 10x productivity. Stick with it, and you'll never look back.

The Modes

Vim is modal. This is its superpower. You don't just type; you command the editor.

Mode Key Description
Normal ESC The default. Navigate and manipulate text here.
Insert i Type text like a mere mortal.
Visual v Select text.
Command : Execute editor commands (save, quit, config).

Pro Tip: Map your Caps Lock to ESC. You'll use it thousands of times a day. Your pinky will thank you.

Insert Mode (The Boring Part)

This is where you type. It works like Notepad. Don't spend too much time here.

To enter Insert mode from Normal mode:

Key Effect
i Insert before cursor
a Insert after cursor
o Insert new line below
O Insert new line above
A Insert at end of line

Normal Mode (Where Magic Happens)

This is where you should live.

Navigation

Forget the arrow keys. They are too far away. Stay on the home row.

Key Movement
h Left
j Down
k Up
l Right
w Jump forward by word
b Jump backward by word
$ Jump to end of line
0 Jump to start of line
gg Jump to top of file
G Jump to bottom of file

Editing

Editing in Vim is composable. d is delete, w is word. dw deletes a word. See the pattern?

Command Action
dd Delete (cut) current line
yy Yank (copy) current line
p Paste after cursor
u Undo
cw Change word (delete word and enter insert mode)
x Delete character under cursor

Visual Mode

Select text like a pro without leaving the keyboard.

  • v: Character-wise selection
  • V: Line-wise selection
  • Ctrl + v: Block-wise selection (Great for multi-line edits)

Once selected:

  • y to yank (copy)
  • d to delete (cut)
  • > to indent
  • < to un-indent

Search and Replace

Stop scrolling. Search instead.

  • /{pattern}: Search forward
  • ?{pattern}: Search backward
  • n: Next match
  • N: Previous match

10x Trick: Use :%s/foo/bar/g to replace all instances of "foo" with "bar" globally.

The .vimrc

Vim out of the box is... raw. You need to configure it. Create a ~/.vimrc file and add these basics to instantly improve your experience.

~/.vimrc
" Enable syntax highlighting
syntax on
 
" Show line numbers (absolute and relative)
set number
set relativenumber
 
" Better searching
set ignorecase
set smartcase   " Case sensitive if you type uppercase
 
" Tab settings (spaces > tabs, fight me)
set expandtab
set shiftwidth=2
set tabstop=2
 
" Enable mouse support (for when you're lazy)
set mouse=a

Bonus: Window Management

Multitasking is essential.

  • :vsp filename: Vertical split
  • :sp filename: Horizontal split
  • Ctrl + w then h/j/k/l: Move between splits

Master these basics, and you'll be editing text faster than you can think. Now go practice. :wq