How to display the current column in the status line?
Having read :h statusline I found %c which looks promising, but it counts
bytes and not characters. I'd like to have the column separated by characters,
not bytes. %v works if no tabs are being used. Here an example:
123 56789
“äå µåäö”
^ this is a tab
I'd like to display the number indicated in the first row. The following works for the first to third column until the tab comes into play.
:set statusline=%v
The following works only for the first line, but not the second one.
:set statusline=%c
Given the abovementioned example vim displays 5 if the cursor is on the
digit five in the first row, which is what I want. If I move down one row so
the cursor is located on the µ I'd like to display 5 as well, %c
displays 9 and %v depends on the value of tabstop.
I think you have to use an expression in the
'statusline'option:%{<exp>}. So grab the line, trim it to the cursor column, replace all characters with a 1-byte character, and count the length of the string: