I already know that a and i makes the cursor one space to the right and left respectively, but when would I use i to edit a file? Is there some special circumstance that makes insertion mode more useful than appending the text?

  • Sorry, but I can't really tell what you mean by insert here, can you please clarify? One reason why you need an a command is that you can't put the cursor after the last character of the line, so you can't really use i to start Insert mode after the current end of the line. (An exception being an empty line.) But not sure whether that's what you mean...
    – filbranden
    Nov 30 '20 at 2:10
  • do you mean :insert? like the ed command?
    – Mass
    Nov 30 '20 at 2:22
  • sorry, i just edited it. i meant like a and i for editing a file (insertion and appending) Nov 30 '20 at 2:56
  • 3
    Vim has many commands (almost) duplicating each other. This is just normal.
    – Matt
    Nov 30 '20 at 5:17
  • 4
    you use whatever you need for your particular situation. Nov 30 '20 at 7:44

It depends if you can edit where your cursor is or if you need to move your cursor.

For example, you have the following:

Your cursor here
[...] hell [...]

and want to change hell into shell, you'd use i, to be in the good place directly (rather than using append, and move the cursor with the arrow key while in insert mode).

However, if you have the following:

Your cursor here
[...] hell [...]

And want to change hell into hello, you'd do e to go at the end of the word, and then press a to start editing after the last l to add the missing letter.

  • 1
    Well, I would press I and A out of habit given the beginning and end of line, but nice demonstration.
    – D. Ben Knoble
    Nov 30 '20 at 14:35
  • Agreed. The example was more like with potential context around, I'll update the answer.
    – padawin
    Nov 30 '20 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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