Vim

Modal text editor for lightning-fast editing - keyboard-only workflow available on every server

TL;DR

One-liner: Vim is a modal text editor that’s fast, efficient, and available on every Unix system - mastering it makes you faster at editing text forever.

Core Value:

  • Speed - keyboard-only workflow, no mouse needed
  • Ubiquity - installed on virtually every server
  • Composability - commands combine like a language
  • Efficiency - do complex edits with few keystrokes

Quick Start

Open Vim

vim filename.txt    # Open/create file
vim                 # Open empty buffer

Three Essential Modes

  • Normal mode (default): Navigate and run commands
  • Insert mode: Type text (press i to enter)
  • Command mode: Run commands (press : to enter)

Survival Basics

i          → Enter insert mode (start typing)
Esc        → Return to normal mode
:w         → Save file
:q         → Quit (fails if unsaved changes)
:wq        → Save and quit
:q!        → Quit without saving

First Edit

vim hello.txt      # Open file
i                  # Enter insert mode
Hello, Vim!        # Type your text
Esc                # Return to normal mode
:wq                # Save and quit

Cheatsheet

CommandDescription
h j k lMove left/down/up/right
w / bMove word forward/back
0 / $Move to line start/end
gg / GGo to first/last line
xDelete character
ddDelete line
yyCopy (yank) line
pPaste after cursor
uUndo
Ctrl+rRedo
/patternSearch forward
n / NNext/previous match
ciwChange inner word
diwDelete inner word
.Repeat last command

Insert mode shortcuts:

CommandDescription
iInsert before cursor
aInsert after cursor
oNew line below
ONew line above
AInsert at end of line
IInsert at start of line

Gotchas

Stuck in Vim (can’t exit)

Esc        → Make sure you're in normal mode
:q!        → Force quit without saving

Can’t type anything

# You're probably in normal mode
i          → Enter insert mode to type

Search and replace

:%s/old/new/g     " Replace all in file
:%s/old/new/gc    " Replace with confirmation
:s/old/new/g      " Replace in current line

Enable line numbers

:set number           " Show line numbers
:set relativenumber   " Relative line numbers

" Add to ~/.vimrc to make permanent
set number

Paste from clipboard

" Before pasting external text:
:set paste
" Paste your text
:set nopaste

Next Steps