I gave another close look at the MoveHorizontally functions. Found a couple of bugs to fix and figured out a way to put the movement logic in a single place. That are three main changes in this PR:
1) Improved the workaround for the problem of virtualedit putting the cursor in the wrong place. Instead of fixing the cursor after virtualedit messes up its position, we now disable virtualedit in the cases it is bugged. This means that the [ and ] always point to the correct place and can now be used by our functions. I also reported the bug to the Vim maintainers. They quickly found out what was the problem and already have patches queued up for the next Vim release.
2) The core movement logic MoveCharHorizontally and MoveBlockHorizontally in now in a single function. The trick is that "x" does the same thing as "d" if we are in Visual mode.
3) Uses of virtcol() are replaced by col(), improving how the functions behave in the presence of tabs. See the last commit message for details.
I gave another close look at the MoveHorizontally functions. Found a couple of bugs to fix and figured out a way to put the movement logic in a single place. That are three main changes in this PR:
1) Improved the workaround for the problem of virtualedit putting the cursor in the wrong place. Instead of fixing the cursor after virtualedit messes up its position, we now disable virtualedit in the cases it is bugged. This means that the
[
and]
always point to the correct place and can now be used by our functions. I also reported the bug to the Vim maintainers. They quickly found out what was the problem and already have patches queued up for the next Vim release.2) The core movement logic MoveCharHorizontally and MoveBlockHorizontally in now in a single function. The trick is that "x" does the same thing as "d" if we are in Visual mode.
3) Uses of virtcol() are replaced by col(), improving how the functions behave in the presence of tabs. See the last commit message for details.