How to set cursor to after last character in vim?

11

4

Why can't I insert at the end of a line in vim if there's no whitespace at the end? Let's take for example my SSH config file:

enter image description here

I try to use $, l, e, but I can't seem to get to the end of the word. When I start typing in insert mode, I get the following:

enter image description here

What gives? How do I make sure I can insert at the very end of a line?

Kenneth Worden

Posted 2015-05-23T01:51:20.050

Reputation: 215

Answers

17

What you want is to use is the a command instead of the i command to enter insert mode. Or if you want to jump to the end of the line and start insert mode, use A. Note that I will jump to the beginning of the line and enter insert mode.

Heptite

Posted 2015-05-23T01:51:20.050

Reputation: 16 267

Works, thanks. Note that I didn't put I, but l, which look the same :/ – Kenneth Worden – 2015-05-23T02:06:36.680

I did see that, but it was clear from context that you were trying to position the cursor for the i command, so I responded accordingly. – Heptite – 2015-05-23T02:07:19.140

2

You can also put set ve+=onemore into your .vimrc; that'll let you put the cursor onto the "empty" space at the end of every line.  Note that $ will still put you on the last character; you'll need to use something like $l (lowercase "L"),  /$Enter or  99| (vertical bar).

Martin

Posted 2015-05-23T01:51:20.050

Reputation: 31