20

I used to enter insert mode by a never realizing that there is a system as to where the insert mode starts.

I was sometimes annoyed that a would put the cursor after the first character of a line, yet the thing is: It enters the insert mode after the current cursor position.

Then I realized I could enter insert mode at the end of the line using A, or below the current line using o.

What are the ways in normal mode to enter insert mode and what is their difference?

2
  • 1
    :h inserting - also :h replacing
    – VanLaser
    Nov 27, 2015 at 23:20
  • @VanLaser You can add that as an answer ^^
    – k0pernikus
    Nov 27, 2015 at 23:21

1 Answer 1

37

Entering insert mode at different locations

The vim help documents have a great section on this: :help inserting

A quick summary is:

  • i: Insert before the cursor.
  • I: Insert before the first non-blank character of the line.
  • a: Insert after the cursor.
  • A: Insert at the end of the line.
  • o: Begin a new line below the current line and insert.
  • O: Begin a new line above the current and insert.
  • gI: Insert at column 1 of the line.
  • gi: Insert where insert mode was last stopped.

Insert commands take a count as well, so you can type 3itest<space><esc> to get:

test test test 

Insert commands can be repeated with . as well, so itest<space><esc>.. will yield (because the i inserts before the cursor, which is on the space):

testtesttest 

Finally, I'll add EvergreenTree's answer from the comments: You can enter insert mode with :star[tinsert][!] which works like i unless you give it the option !, in which case it works like A.

Modifying text and then entering insert mode

It is also possible to modify the text in normal mode and enter insert mode at the end. See :help replacing. A summary of the commands are as follows:

  • c: Delete text (and yank to the buffer) and enter insert mode.
  • cc: Delete the line and enter insert mode.
  • C: Delete until the end of the line and enter insert mode.
  • s: Delete a number of characters and enter insert mode.
  • S: Delete a number of line and enter insert mode.

Many of these also work on visually selected text.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.