Is there a setting that will allow vim to remember the column it was on, even if traverses a line who's EOL is less?

Consider the following lines:

foo bar
foo
foo bar

Say my cursor position is the underscore:

foo b_r
foo
foo bar

If I hit jj, the cursor ends up here:

foo bar
foo
fo_ bar

But I want it to remember where it is on line 1 and go there on line 3 since it's available.

foo bar
foo
foo b_r

EDIT: When I disable minibufexpl.vim, the problem goes away, so it's a problem with that plugin. Anyone know what's up?

link|improve this question

Are you sure it doesn't? Vim tries to keep the cursor on the same column. – El Isra Apr 12 '11 at 20:40
feedback

2 Answers

up vote 1 down vote accepted

It should go to the same column by default. Have you tried starting Vim as

$ vim -N -u NONE

or

$ gvim -N -u NONE

and performing your experiment again?

One thing that can cause this behavior is a plugin that uses the CursorHold autocommand. If such an autocommand performs certain actions when it executes, it will cause your cursor to move as you describe. You can check for the existence of such autocommands with

:au CursorHold
link|improve this answer
minibufexpl.vim is the culprit. Now to figure out what the problem is... – mattalexx Apr 12 '11 at 21:58
I wrote a plugin that used the CursorHold autocommand event and had that problem with the cursor column. Vim resets the remembered cursor column to the current cursor column whenever an option is set, so I changed the code invoked by the CursorHold event to set options only when necessary. The minibufexpl plugin might have the same issues. – garyjohn Apr 12 '11 at 22:19
feedback

Since I don't have enough reputation to comment on your question, I'll post as an answer instead.

Have you tried set virtualedit=all?

link|improve this answer
Yes, but that includes some stuff that I don't want, like having your cursor past EOL. – mattalexx Apr 12 '11 at 20:36
feedback

Your Answer

 
or
required, but never shown

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