Insert Mode


As you might guess, insert mode is used to insert text into the buffer.

The most common way to switch from normal mode to insert mode is to type i, but this is such a common operation that Vim provides a variety of commands that fine-tune how it does so. Additionally, each of these commands accepts an optional count:

CommandAction
iinsert text before the cursor N times
aappend text after the cursor N times
s(substitute) delete N characters [into register x] and start insert
Iinsert text before the first CHAR on the line N times
Aappend text after the end of the line N times
Sdelete N lines [into register x] and start insert; synonym for "cc".
Cchange from the cursor position to the end of the line, and N-1 more lines [into register x]; synonym for "c$"

Let's take a look at a few of these to get a better idea of some of the functionalities that are available. First, let's look at entering insert mode using i:

Initial Conditions
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·always·give·it·meaning·and
transform·it·into·something·of·value.
NORMAL60%3:13
 
Enter INSERT Mode withi
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·always·give·it·meaning·and
transform·it·into·something·of·value.
INSERT60%3:13
 
Insert textABCD
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·alwayABCDs·give·it·meaning·and
transform·it·into·something·of·value.
INSERT60%3:17
 

Note that in Step 1 the editor is in normal mode, and the cursor covers the entire character at its current position, while in Step 2 the editor is in insert mode, with a "bar" style cursor that is located before the cursor.

Compare that behavior with that of using a, as shown in the following example. Repeating that example produces the following:

Initial Conditions
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·always·give·it·meaning·and
transform·it·into·something·of·value.
NORMAL60%3:13
 
Enter INSERT Mode witha
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·always·give·it·meaning·and
transform·it·into·something·of·value.
INSERT60%3:14
 
Insert textABCD
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·alwaysABCD·give·it·meaning·and
transform·it·into·something·of·value.
INSERT60%3:18
 

The main difference is in Step 2, where entering insert mode with a places the cursor after the current position.

Finally, let's compare both of the previous examples with the behavior of entering insert mode with s:

Initial Conditions
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·always·give·it·meaning·and
transform·it·into·something·of·value.
NORMAL60%3:13
 
Enter INSERT Mode withs
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·alway·give·it·meaning·and
transform·it·into·something·of·value.
INSERT60%3:13
 
Insert textABCD
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·alwayABCD·give·it·meaning·and
transform·it·into·something·of·value.
INSERT60%3:17
 

In this case, the character under the cursor is deleted, then new text is inserted in its place.

As shown in the table above, each of these commands has a "capitalized" version that has a similar behavior, but performed on the line-level. It can be a big benefit to practice each of these and commit them to muscle memory.