Is there a way to show the current row and column position in vi? In vim, I know there is the
set ruler command, but what are my options when using vi?
You can do
set number to show the line number at the beginning of each line. However, in original vi, there doesn't seem to be an option to show the current column.
There is a way to at least position the cursor at a specific column. Do
25| to position the cursor at column 25 of the current line.
You can press Ctrl+G to temporarily display some useful information in the bottom left corner, including line- and column number of the cursor, the name of the file and more.
Original vi had nothing like the
ruler mode which you see in
In original vi (such as AIX, HPUX, Solaris), pressing controlG shows which line you are on, but not the column, e.g.,
"shlib" [Read only] line 137 of 140 --97%--
The ruler mode was first introduced in
elvis (see how to draw a line in vi at 80 columns):
google shows me that elvis added this in version 1.5 (April 2, 1992), and for reference, version 1.4 was August 4, 1991.
It was added to vim in version 1.18 (undated) between 1.17 (April 20, 1992) and 1.24 (January 10, 1993):
VIM 1.18 - Screen was not updated when all lines deleted. Readfile() now puts cursor on first new line. Catch strange disk label. Endless "undo line missing" loop removed. With empty file 'O' would cause this. Added window size reset in windexit(). Flush .vim file only when buffer has been changed. Added the nice things from Elvis 1.5: Added "equalprg" and "ruler" option. Added quoting.
nvi started as a fork of elvis, and inherited this code. Some people see nvi running and suppose it to be original vi.
vile added a ruler mode in changes for version 3.57 (August 5, 1993). So all four of the common vi-clones provide a
Using the vertical bar to get to a particular column is a workaround (which in a quick check does account for tab-stops).
Further reading: vi like emacs - FAQ
OK so this is from memory, from years ago.
Vi has a status bar line - and I've seen it setup to report the column number of the cursor in the status bar... just don't remember how that was accomplished.
Yes, this was vi not vim - on solaris, or sunos maybe.