Table of Contents
Neovim Editing
Text insertion and deletion are the core of editing in Neovim. Most operations combine a verb (operator) with a subject (motion or text object).
Insert modes
i — insert before cursor, a — insert after cursor. I — insert at line start (first non-blank), A — insert at line end.
o — create new line below and insert, O — new line above and insert.
All insert modes exit with Esc. Ctrl+C also exits but is slightly different (doesn't set . for repeat).
i text <Esc> " insert "text" before cursor A ; <Esc> " append semicolon at line end o print("x") <Esc> " new line, insert code
Delete and change
x — delete char at cursor, X — delete char before cursor. Delete is quick removal without affecting position much.
dd — delete entire line, d3d or 3dd — delete 3 lines. D — delete from cursor to end of line.
dw — delete word, db — delete to previous word boundary. d$ — delete to end of line, d^ — delete to first non-blank.
c — change (delete and insert). cw — change word, cc — change line, c$ — change to end of line. After change, cursor enters insert mode automatically.
x " delete char at cursor dd " delete line dw " delete word c2w hello " delete next 2 words, type "hello" cw new_name <Esc> " replace word at cursor
Case and character replacement
r — replace one character. rX replaces char at cursor with X. R enters replace mode (like insert but overwrites).
~ — toggle case of char at cursor (upper ↔ lower), g~w — toggle case of word, guw — lowercase word, gUw — uppercase word.
Line operations
J — join next line to current (with space). gJ — join without adding space.
u — undo last change, U — undo all changes on current line (within one edit session). Ctrl+R — redo.
. — repeat last command. Extremely powerful: edit once, repeat with . on other lines.
J " join lines u " undo . " repeat last edit J . . " join 3 lines quickly
Indentation and shifting
>> — indent line right (by shiftwidth), << — indent left. >ip — indent paragraph. < and > work with motions.
For multiple lines, select in visual mode then press > or <.
