Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
Vi(since 1978) doesn't have most of features which ViM (since 1991) has introduced. And most Vi-like editors doesn't extend much Vi command and option set. – Eir Nym Nov 19 '11 at 15:25

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.

share|improve this answer

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.

share|improve this answer

Original vi had nothing like the ruler mode which you see in vim.

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 ruler mode.

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

share|improve this answer

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.

HTH, -pbr

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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