Visual indent leaves cursor at incorrect location #183

Closed
jordwalke opened this Issue Apr 5, 2013 · 5 comments

Comments

Projects
None yet
2 participants

Insert:

one
two
three

Place your cursor in normal mode on the three. Press V for linewise visual mode. Move up to the one to select all three lines. Then press >. Your cursor should remain at the top on line one - this is what vim does. The current cursor behavior of jumping back down messes up the repeat command.

I notice that when selecting from the top down, and shifting with >, everything works.

The Vim behavior seems to be: Always leave the cursor at the topmost part of the selection, regardless of where the selection began. Strange but works well and is engrained into my muscle memory.

Owner

guillermooo commented Apr 5, 2013

It seems Vim normalizes motions to always be top-down. That makes sense. This one looks like a big feature.

BTW, if you try repeating in line 'three', you do get the expecter result, right?

Owner

guillermooo commented Apr 5, 2013

Potential fix:

  • tag all downward motions

The first run of a command including downward motions would run normally. When repeating, we'd include an 'is_repeating' flag so 'vi_run' knows it must reverse the motion. I suppose that means we'd need to define antonyms for each downward motion too. This should work for visual line mode; not so sure about visual mode.

Owner

guillermooo commented Apr 5, 2013

Then again, I haven't double-checked with Vim wether the reversal occurs in every mode. I suspect it might be only in visual line mode, which would be geat news.

I believe that if I try repeating at line three it does the correct thing (but I have to move my cursor there - it doesn't even remain at three when selecting bottom up - indenting moves my cursor down one extra line oddly)

guillermooo was assigned May 25, 2013

Owner

guillermooo commented May 30, 2013

This one seems pretty tough to solve. I need to think longer about how to reverse the motion's direction when repeating commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment