I'm looking for a shell utility or program which will allow me to interactively view a text file as I can with the built in less command and also display a fixed ruler at the top of the screen so that I can see the exact column offset at all times for each character.

This functionality is built into some DOS utilities, such as the ancient list.com and 4Dos. Here is a screenshot from the the list command which shows what I'm looking for:

enter image description here

I've searched but have not been able to find any solution for this in a unix based shell. Anyone know a way to do this?

Conventional shells won't do this. Occasionally someone mentions a visual shell, but (a) a quick check finds none mentioning the feature and (b) those are not used a lot.

Text editors may have the feature (but that's not what you are asking for).

A terminal application such as screen or tmux would be a suitable place to add this feature (but neither does this).

For what it's worth, I do this in an application not a text editor, ded (directory editor), and find it useful for viewing files:

screenshot from ded

(the ruler can be moved up/down, interactively).

  • Appreciate the confirmation that I have not overlooked anything glaringly obvious. I find it a bit odd that there is no clear cut way to do this. I used this feature of list all the time back in my DOS/Windows days. I would settle for a solution in vim but had no luck with that either. My only real requirement is that it work in an SSH session and allow measuring column offset in a line. – Mark Edington Feb 11 '17 at 18:17

You can view a text file in ViM and use:

:set colorcolumn=72

This will not give you a ruler, but it will give you a visual marker.

ViM can be configured to be a direct replacement for less.

Note: The following method does not account for horizontal scrolling in applications like less. It is a column-ruler for the terminal itself, not a particular file.

GNU screen can be convinced to do this, though it does not have a built-in command explicitly for this purpose. Create a file .screenrc containing:

hardstatus alwaysfirstline "----|----10---|----20---|----30---|----40---|----50---|----60---|----70---|----80---|----90---|----100--|----110--|----120--|----130--|----140--|----150--|----160--|----170--|----180--|----190--|----200"

Of course, you can extend the string to as many columns as you feel you might need. It will be truncated to fit the width of your terminal upon display, so you do not need to worry about it wrapping onto multiple lines.

Then execute:

$ screen

and you will have a column-ruler much like the one you show in your screenshot. Note that, by default, Ctrl+A is a command-character for screen. If you use that key sequence frequently you may want to change that default via an escape line in .screenrc — see screen(1) for details.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.