Vim's natural resting state. This is different to most other editors which spend their default time in something like insert mode.
Many normal mode commands can be execute with a count to run them multiple times.
Normal mode commands can be combined with movement operators to define the extent of their effect.
7. Pause with your Brush off the Page
- Most of the time spent writing is not actually spent entering text. A lot is taken up by thinking, reading, navigating.
- Also a lot of editing does not get done in insert mode e.g. copy and pasting, deleting, reformatting.
8. Chunk your undos
- In VIM we can control the granularity of the undo command. The undo command
uwill undo the last portion of text entered in insert mode.
- So by regularly dropping back out to normal mode we can make uno operate on the size of text of our choosing.
- For example escaping to normal mode after eaach sentence means that undo will operate on the sentence leve.
- In practice escape back to normal mode and press A to append text.
- Or to enter a newline use
- If you've paused long enough to leave insert mode then do it!
9. Compose repeatable changes
- There's often more than one way to do things in vim. If there is a choice then choose the one than can be repeated using the dot operator.
- This will often be a single command that has the selection embedded into it e.g.
daw, as opposed to one or two commands where the dot would only repeat the last part e.g.
10. Use Counts to Do Simple Arithmetic
- Many of the commands available in normal mode can be prefixes with a count to indicate how many times vim should execute the command.
Ctrl-xperform addition and subtraction on numbers. These can be prefixed with a count to add or subtract a specific number.
- Cursor doesn't have to be on the number. These operate on the next number after the cursor.
- Vim treats numbers beginning with a leading 0 as octal. To force all numbers to be treated as decimal add
set nrformat=to the
11. Don't count if you can repeat
- When you use count then the undo command operates on the full counted operation e.g. d6w will delete six words and
uwill undo all of those changes
- If you use repeat then
uis more granular.
dw.....will also delete six words but each
uwill undelete a single word.
- It depends on the use case which is better for you - a more coherent undo history or a more granular one.
12. Combine and Conquer
- Operator + Motion = Action
- Operators can operate on a wide range of text objects e.g. single character, complete word or entire paragraph.
- This is defined by the motion entired after the operator e.g.
awfor a word or
apfor a paragraph.
- Some operators are two characters e.g.
g~to change case.
- When an operator is invoked in duplicate then it operates on the entire line.
- We can make custom operators which operate on the existing motions and also custom motions e.g. entire file which can handle the existing operators.