In ViM, the ruler can be enabled by typing:
When enabled, the ruler is displayed on the right side of the status line at the bottom of the window. By default, it displays the line number, the column number, the virtual column number, and the relative position of the cursor in the file (as a percentage).
Default Ruler Format
The ruler format can be set by using the
rulerformat command. Curiously, the default
rulerformat is empty even though it is displaying the above details! You can find this out for yourself by typing:
A little digging into the ViM source code reveals that the default format is not a
rulerformat string at all. Instead, it is formatted manually in the
win_redr_ruler function of
screen.c in the code! Only Bram Moolenaar must know why he does this manually instead of using rulerformat itself. 🙂
Anyway, a close equivalent of the default rulerformat can be set by using:
:set rulerformat=%-14.(%l,%c%V%)\ %P
The ruler is 18 characters in length by default. (It is not 17 as the ViM documentation in options.txt claims.) 14 characters (
%-14) is the minimum width reserved for line, column and virtual column numbers (
%l,%c%V%). A space separates that from the relative position display (
%P) which is always 3 characters in length. When rulerformat is not set, if the total length of the ruler information exceeds 18, only the left-most 18 characters are displayed. With the above format, the rightmost 18 characters are displayed.
Note: Check out a simpler alternative for the default ruler format shared by Peter Fröhlich in the comments below.