here's a Vim question that I haven't been able to find the answer for. What does the %V
statusline variable do?
I checked the documentation I could find, but it's not really clear, I am aware it shows the virtual column, but what do the numbers/letters before the -
mean?
For example, what do each of the following mean?
0-1
17-18
etc. From what I can manage, while finding these examples. the number before the -
is the last solid column, real column in other words. Is this correct?
Thanks for your help!
In the Vim statusline
, amongst the many flags you can set, there exist:
%c
-- column number, i.e. byte number.%v
and %V
-- virtual column number, i.e. column number on your screen.So what is the difference between the actual and virtual column number? The answer is, that when using tabs, the virtual column number is an approximation of your current column number as if you were using spaces instead of tabs.
Example. A useful combination in the Vim statusline is:
%c%V
As it says in the help, the %V flag, which displays the virtual column number, will only be printed (with a preceding dash) when it differs from the actual column number. Thus, normally your statusline would show only the real column number (e.g., 8
), but if you are on a line with tabs or multi-byte characters, you will see two numbers (e.g. 1-8
).
For instance, try this:
echo -e "\tHello world." > /tmp/test
Then, open /tmp/test
in Vim and notice your status line indicating the difference between the real and virtual columns. If you change the tabstop
setting to a different value, the virtual column will change.
Finally, if you :set expandtab
and do :retab
, then the virtual column indicator will be hidden.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With