Vim & Nano Commands Cheatsheet

Quick reference for Vim and Nano text editors: navigation, editing, search, and essential keyboard shortcuts.

FeatureDescriptionExampleCategory
Open FileOpen file in Vimvim filename.txtVim Basic
Insert ModeEnter insert modei (insert before cursor) a (insert after cursor) I (insert at line start) A (insert at line end)Vim Basic
Exit Insert ModeReturn to normal modeESC or Ctrl+[Vim Basic
Save FileWrite changes to disk:wVim Basic
Save and QuitSave and exit Vim:wq or ZZVim Basic
Quit Without SaveExit without saving:q!Vim Basic
Visual ModeEnter visual selection modev (character) V (line) Ctrl+v (block)Vim Basic
Move CursorBasic cursor movementh (left) j (down) k (up) l (right)Vim Navigation
Word MovementMove by wordsw (next word) b (previous word) e (end of word)Vim Navigation
Line MovementMove within line0 (line start) $ (line end) ^ (first non-blank)Vim Navigation
Page MovementScroll pagesCtrl+f (page down) Ctrl+b (page up) Ctrl+d (half page down) Ctrl+u (half page up)Vim Navigation
File NavigationJump to file positionsgg (file start) G (file end) :42 (go to line 42)Vim Navigation
Screen PositionMove cursor on screenH (top of screen) M (middle) L (bottom)Vim Navigation
Delete CharacterRemove single characterx (delete under cursor) X (delete before cursor)Vim Editing
Delete LineRemove entire linedd (delete line) D (delete to end of line)Vim Editing
Delete WordRemove worddw (delete word) de (delete to end of word)Vim Editing
Undo/RedoUndo or redo changesu (undo) Ctrl+r (redo)Vim Editing
Copy (Yank)Copy textyy (yank line) yw (yank word) y$ (yank to end of line)Vim Editing
PastePaste yanked/deleted textp (paste after) P (paste before)Vim Editing
ReplaceReplace charactersr (replace char) R (replace mode) cw (change word)Vim Editing
Join LinesJoin current line with nextJVim Editing
Search ForwardSearch from cursor down/patternVim Search
Search BackwardSearch from cursor up?patternVim Search
Next/PreviousNavigate search resultsn (next) N (previous)Vim Search
Find and ReplaceSubstitute text:%s/old/new/g (all file) :s/old/new/g (current line)Vim Search
Find CharacterJump to character in linef{char} (forward) F{char} (backward) t{char} (till forward)Vim Search
Open File (Nano)Open file in Nanonano filename.txtNano Basic
Save (Nano)Write changes to diskCtrl+O (WriteOut) Enter to confirmNano Basic
Exit (Nano)Exit Nano editorCtrl+XNano Basic
Help (Nano)Display help menuCtrl+GNano Basic
Cancel (Nano)Cancel current operationCtrl+CNano Basic
Cut Text (Nano)Cut current line or selectionCtrl+KNano Editing
Paste (Nano)Paste cut textCtrl+UNano Editing
Copy (Nano)Copy text (mark first)Alt+6 (after marking with Alt+A)Nano Editing
Mark Text (Nano)Start text selectionAlt+A or Ctrl+6Nano Editing
Search (Nano)Search for textCtrl+WNano Editing
Replace (Nano)Search and replaceCtrl+\ or Alt+RNano Editing
Go to Line (Nano)Jump to specific lineCtrl+_ then enter line numberNano Editing
Delete (Nano)Delete characterDel or Ctrl+DNano Editing
Undo (Nano)Undo last actionAlt+UNano Editing
Redo (Nano)Redo last actionAlt+ENano Editing