Difference between append and insert mode in Vim
VimVim Problem Overview
I noticed this accidentally when playing around in vimtutor. What's the difference between append and insert mode in Vim? When I type a
in normal mode (not A
) I can insert text. When should I use one and not the other?
Vim Solutions
Solution 1 - Vim
The append command will put the cursor after the current position, while the insert command will put the cursor before it.
Using the append command is like moving the cursor one character to the right, and using the insert command.
Using the insert command is like moving the cursor one character to the left, and using the append command.
You choose which depending on where you want to start typing.
Solution 2 - Vim
Note that vimtutor
doesn't initially make the case of the command obvious:
SHIFT+A (capital A, as opposed to a) the cursor moves to the end of the current line.
SHIFT+I (capital I, as opposed to i)moves to the start of the current line.
Solution 3 - Vim
Another important aspect on Append is that if the position after the current position is a empty space followed by a word. After you are done writing it will concatenate both words.
E.g. A file with the following text:
Hi there.
With the cursor on i. After pressing the a button and then ESC you would have:
Hithere.