Screen Ruler


A ruler tool is useful to check pixel distances on the display and to check if artifacts in photos are perfectly horizontal or vertical. The Screen Ruler tool on Ubuntu does this job perfectly.

It can be installed easily from Ubuntu repositories:

$ sudo apt-get install screenruler

It can be started from the Dash as Screen Ruler. Note that this application uses Ruby and will install that.

Tried with: Screen Ruler 0.9.6 and Ubuntu 12.04 LTS

ViM: Ruler and Default Ruler Format

In ViM, the ruler can be enabled by typing:

:set ruler

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:

:set rulerformat?

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.