Picking the right insert command removes a lot of small cursor movements.
There are several ways into Insert mode, each starting at a different place:
iinserts before the cursor,aappends after it.Iinserts at the first non-blank character of the line,Aappends at the end of the line.oopens a new line below and enters Insert mode,Oopens one above.sdeletes the character under the cursor and inserts;S(same ascc) clears the whole line and inserts, keeping indentation.
So to add a semicolon at the end of a line, type A;<Esc> from anywhere on the line, rather than $a;<Esc>. That matters more than it looks: as a single command, A; can be repeated on other lines with . (covered in the undo lesson).
While in Insert mode a few keys are handy:
Ctrl-wdeletes the word before the cursor,Ctrl-udeletes back to the start of the insert.Ctrl-nandCtrl-pcomplete words that appear in open buffers.Ctrl-oruns one Normal-mode command and comes straight back to Insert mode.
A count also works: 3ihey <Esc> inserts hey hey hey . Leave Insert mode as soon as you are done typing; Normal mode is the home base.
Example
A;<Esc> " append ';' at end of line
I// <Esc> " comment out: insert '// ' at first non-blank
o<Esc> " add an empty line below
Oimport os<Esc> " add a line above
3i-<Esc> " insert '---'
S " wipe line contents (keeps indent) and insertRemember
- i/a = before/after cursor, I/A = start/end of line, o/O = new line below/above
- A single insert command can be repeated with .
- Ctrl-w deletes the previous word while typing