0

When I step over a tab with the cursor keys (h and l), the cursor does not jump over the tab, it just goes one space at a time. This is annoying because I am not sure if there is a tab there or spaces. What I expect is that if I move onto a tab the cursor should situate at the beginning of the tab (the leftmost position) and if I move one space to the right, it should jump to the first character after the tab.

How can I achieve this behavior?

Note that I am using visualedit=all.

2

I assume you mean virtualedit instead of visualedit (which does not exist)?

You need to disable virtualedit in normal mode, as this option defines the handling of tabs for the possible cursor positions; Instead of all, use all other values together:

:set virtualedit=insert,block,onemore

From vim documentation, :help 'virtualedit':

'virtualedit' 've'  string  (default "")
    A comma separated list of these words:
        block   Allow virtual editing in Visual block mode.
        insert  Allow virtual editing in Insert mode.
        all     Allow virtual editing in all modes.
        onemore Allow the cursor to move just past the end of the line

    Virtual editing means that the cursor can be positioned where there is
    no actual character.  This can be halfway into a tab or beyond the end
    of the line.  Useful for selecting a rectangle in Visual mode and
    editing a table.


From this description, it seems to be not possible to have virtualedit=all, except the jump-over-tabs part.

A possible way to implement that is remapping the keys h and l to jump over tabs explicitly in normal mode, and keep virtualedit=all.

  • Right, but there is a difference between positioning the cursor where there is no text and positioning in the middle of a tab. Ideally I would like to be able to move the cursor past the end of the line (for editing tables and comments) but still have the cursor respect existing tabs. Not going to happen? – Tyler Durden Sep 9 '14 at 6:33
  • I agree that makes sense to have, but from the help for 'virtualedit', seems like no, not possible. – Volker Siegel Sep 9 '14 at 6:36
  • What about remapping the keys h and l to jump over tabs explicitly in normal mode? – Volker Siegel Sep 9 '14 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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