Make vim change its cursor behavior

cursorvim

I've been using vim for a few years as a secondary editor but for various reasons, I find myself using it more and more even when my primary editor is available. One problem that has always bugged me about vim, and that keeps me from using it more, is the way it handles cursor placement. The cursor can only be on a character, rather than between characters, as would be the case with any editor created since 1984.

For just one example of why this is a problem, if I want to delete the last word on a line, I hit $ to go to the end of the line, and then db to delete backward. This leaves a character to delete, because $ didn't really go to the end of the line, it went to the last character of the line, and db deleted only what was before the current character. The problem isn't that I have to type an extra character, it's the extra thought involved in doing what ought to be simple, which distracts my attention away from what I'm actually trying to accomplish.

It seems to me that the more modern idea cursor placement is in every way superior, and I'd like to switch vim to use that approach. I'm sure some hard-core vim fans will disagree with my view on that, but since one of the standard arguments for vim's superiority is its infinite configurability:

  • can it deliver in this case?
  • Can vim be made to place the cursor between characters?

Best Answer

You can :set virtualedit+=onemore, which allows you to go just past the last character. Unfortunately for you, $ still goes to the last character; you have to cursor over to get past it. On the other hand, you can use g$, which normally goes to the last character of the screen line on a line that wraps; in onemore mode it also goes just past the last character of a non-wrapped line (or the last screen line of a wrapped line).

:h 'virtualedit' says this option can mess up scripts, but I don't know how big a risk that is in reality.

Related Question