Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Have you tried set virtualedit=all? –  shurane Apr 12 '11 at 20:33
    
Yes, but that includes some stuff that I don't want, like having your cursor past EOL. –  Matt Alexander Apr 12 '11 at 20:36
    
Are you sure it doesn't? Vim tries to keep the cursor on the same column. –  Raimondi Apr 12 '11 at 20:40
add comment

1 Answer

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
share|improve this answer
    
minibufexpl.vim is the culprit. Now to figure out what the problem is... –  Matt Alexander 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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