Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 bar

Say my cursor position is the underscore:

foo b_r
foo bar

If I hit jj, the cursor ends up here:

foo bar
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 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? – Ehtesh Choudhury 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
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


$ 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .