3

I'm using Vim on Cygwin. Basically, Vim won't allow me to move past the last character on a line when I'm in normal/command mode. It will let me move right before the last character but not after it. Any thoughts on what might be wrong?

  • 2
    If you have a line containing the single word foobar and you hit on the $ key, does your cursor land on the r character ? (meaning if you hit x you get fooba) If you want your cursor to move past the last character on the line, you could try the following command: :set virtualedit+=onemore – saginaw Feb 14 '16 at 5:57
  • @saginaw Yeh if I hit x I do get fooba. But if I hit the $ key nothing happens – Joel Feb 14 '16 at 6:01
  • @saginaw Thanks that solved it. Would you mind explaining what that did and why that was not the default setting? – Joel Feb 14 '16 at 6:02
  • 2
    Vim's cursor is always on a character position, never between character positions, even though some cursor shapes make it appear that the cursor is between character positions. When your cursor appears to be before the last character, it is probably on the last character. That is Vim's normal behavior. You can change it, if you like, by following saginaw's suggestion. – garyjohn Feb 14 '16 at 6:03
  • 1
    @saginaw Since I am using Vim on Cygwin, my cursor is in between the characters, rather than on a character for some reason. Therefore it ends up before the last character rather than on it. Your fixed solved the problem though. Thanks. – Joel Feb 14 '16 at 6:11
5

Vim's cursor is always on a character position, never between character positions, even though some cursor shapes make it appear that the cursor is between character positions. When your cursor appears to be before the last character, it is probably on the last character. That is Vim's normal behavior. You can change it, if you like, by following saginaw's suggestion of using the command

:set virtualedit+=onemore

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.