VI Notes
· ☕ 5 min read · ✍️ Ben Mason
vi notes Searching and Replacing in vi
Edit Modes i – activates text insert mode, inserting text immediately under the current position of the cursor R – Replace / Overwrite a – append text, after the cursor A – append text, after end of line I – insert text, before first non-whitespace character o – open new line below cursor in Insert Mode O – open new line above cursor in Insert Mode Movement l – moves the cursor one character to the right h – moves the cursor one character to the left (2h moves the cursor two characters to the left) j – moves the cursor one line down (3j moves the cursor three lines down) k – moves the cursor one line up G – moves the cursor to the last line of text if not preceded by a modifying integer nG – moves the cursor to the desired line (5G moves the cursor to the fifth line) w – moves to next word $ – end of line 0 – begining of line % – Navigate to matching brace or parenthis >% – indent between selected braces >> – indent line Deletion x – deletes the character immediately under the cursor X – deletes a single character to the left of cursor D – removes the text on the current line from the character under the cursor to the end of the line dw – deletes the character immediately under the cursor and the remaining characters to the right of it in the same word dd – deletes the entire line containing the cursor, and the cursor then moves to the next line cw – deletes the character under the cursor and to its right in the same word and allows new characters to be typed in to replace them cc – erases the current line and allows replacement text to be typed in cb – deletes the characters to the left of the cursor in the current word and allows replacement characters to be typed in Search /string – search ?