TransWikia.com

How to show the current column in the statusbar in vim?

Super User Asked on December 3, 2020

I would like to show the current column in the statusbar, as is common in many other text editors. E.g. it’s good to know if you are around column 80 or above.

How to show the current column in the statusbar?

7 Answers

Try if setting 'ruler' option is what you are looking for. On my computer at the bottom right shows the line and column where I have the cursor.

:set ruler

EDIT TO COMMENTS:

From the help of vim (command :help ruler):

If the number of characters displayed is different from the number of bytes in the text (e.g., for a TAB or a multi-byte character), both the text column (byte number) and the screen column are shown, separated with a dash.

You can try changing it with rulerformat option, like :set rulerformat=%l,%v

Correct answer by Birei on December 3, 2020

For permanent change you can just do:

echo "set ruler" >> ~/.vimrc

Answered by DimiDak on December 3, 2020

Another way to do this is to do 'g Ctrl-G', which prints the current position of the cursor in five ways: Column, Line, Word, Character and Byte. (from http://vimdoc.sourceforge.net/htmldoc/editing.html#g_CTRL-G)

Answered by Peter on December 3, 2020

Or, leave 'ruler' unset, a performance gain, and press CTRL-G when you want to see the current column.

Answered by ma11hew28 on December 3, 2020

For the other people that are looking for this answer and are not used to working with VIm, personally the simplest answer I've found is to add this line to the end of your .vimrc file in your home directory:

set ruler

Answered by Jay on December 3, 2020

I would depreciate using set ruler because I believe it is not compatible with the statusline options, e.g. if you set the statusline to display the full filepath in combination with set ruler

set statusline+=%F

set ruler

Then it does NOT display the column number but just the full filepath in the statusbar. However if you put the following in your .vimrc

set statusline+=%F %l:%c

It will display everything correctly, namely the

[Filepath/filename] [linenumber]:[column number]

Answered by Giovanni Macciocu on December 3, 2020

See :help statusline for the many options available.

I have this in my ~/.vimrc in between a bunch of other directives:

set statusline+=col: %c,

which outputs

col: 64

in my statusline.

I don't have set ruler.

Answered by romainl on December 3, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP