6

I recently noticed that on some help files it is not possible to move the cursor to the very first column of some lines. To explain it clearly, here is a screenshot where I have done the following:

  • vim -u NONE
  • :h help
  • 3j
  • 0

Screenshot of helpfile

As you can see my cursor is not on the first column of the line. And I have no means to put my cursor on it (even using h or any other command).

(Note that I also used :set ft=txt to check if the help syntax wasn't hiding something)

It happens in a lot of different help files but I don't think it happens on all the indented lines, thus I'm wondering what is causing this behavior.


Edit I should have specified this before but I asked the question because this behavior only happens on the help buffers but not on any other buffer, e.g., vim -u NONE ~/.vimrc, I'm able to go to the beginning of the lines:

enter image description here

2
  • 1
    It's called virtualedit. Try it after set virtualedit=all. Jun 27, 2016 at 19:32
  • @SatoKatsura Indeed that solves the behavior I described. Now I don't really see the link with the suggestion of romainl about the list option...
    – statox
    Jun 27, 2016 at 21:19

3 Answers 3

6

By default, the cursor is positioned on the last cell used to display a tab character.

You can change that behavior by enabling the list option and defining custom values for the listchars option (the default ^I for tabs is not very practical):

set list
set listchars=tab:»\ ,extends:›,precedes:‹,nbsp:·,trail:·

(that listchars is mine, use what you want)

See :help list and :help listchars.

In help buffers, the list option is disabled by default so you get the default behavior.

If you absolutely need the ability to move your cursor on the first cell of tabs, you can add the line below to after/ftplugin/help.vim:

setlocal list
4
  • I don't think list and listchar are interfering here: the settings doesn't change between a regular buffer and an help buffer and I don't have this behavior on my other buffers.
    – statox
    Jun 27, 2016 at 13:55
  • list and listchars don't interfere. list is the only practical way to change how tabs are displayed and thus how the cursor is positioned. Also, list is disabled in help buffers.
    – romainl
    Jun 27, 2016 at 14:20
  • @statox it's tab alright: set list and I get this: i.stack.imgur.com/yXb5V.png
    – muru
    Jun 27, 2016 at 15:44
  • I misunderstood your answer at first but now I get it, thanks for the explaination and thanks @muru for the screenshot clarifying it :-)
    – statox
    Jun 27, 2016 at 16:00
1

It's because your cursor is resting on the first character which is a tab. Use setlocal tabstop=1 so you can see what cursor movement looks like. Vim's help files requires tabstop to be set to 8.

1

I had the same issue, was very frustrating for a while, and it just means there is a tab as the first character in the line. Eventually I found it rather useful to know that it is a tab and not space. So one option is to look at this as a feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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