Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to draw a line in vi at 80 columns

647 views
Skip to first unread message

wolverine

unread,
Jan 16, 2007, 5:54:55 AM1/16/07
to
Hi,
Is there any way by which i can make vi draw a line at 80
columns, so that i could see that i am about to hit 80 column limit. I
don't want to use word wrap at 80 columns. I want to see the straight
line at 80 columns.

Thanks in advance
Kiran.

Stephane CHAZELAS

unread,
Jan 16, 2007, 9:30:47 AM1/16/07
to
2007-01-16, 02:54(-08), wolverine:
[...]

If your vi is actually vim, you could do:

:syn on
:syn match Error /\%81v.*/

to visually mark (like white over red) text written past the
80th columns.

--
Stéphane

Frank Cusack

unread,
Jan 16, 2007, 2:28:39 PM1/16/07
to
On 16 Jan 2007 02:54:55 -0800 "wolverine" <kiran...@gmail.com> wrote:
> Is there any way by which i can make vi draw a line at 80
> columns, so that i could see that i am about to hit 80 column limit. I
> don't want to use word wrap at 80 columns. I want to see the straight
> line at 80 columns.

why not just set your terminal width to 80 columns.

-frank

Logan Shaw

unread,
Jan 17, 2007, 3:40:06 PM1/17/07
to

It's not the most beautiful way to do it, but one way is to insert a
line of 80 characters to compare against:

o ESC 80 a x ESC

Then, delete that line later on when you're done editing.

If you want to check whether a given line contains more than 80 columns
of text, that's fairly simple. Just do this:

80 | 0 81 |

On any line 80 columns or shorter, those two "|" commands will go to the
same position. On a longer line, the second "|" command will move
further. You can turn the second number into something larger (like 90)
to make it easier to see the difference.

In some vi-compatible editors, like vim, you can just use control-G to
see what column you're in, which is a bit easier. Then you just need
to type "$ G" to see if the line is longer than 80 columns.

- Logan

wolverine

unread,
Jan 18, 2007, 1:03:22 AM1/18/07
to
Logan Shaw wrote:
> wolverine wrote:
> > Hi,
> > Is there any way by which i can make vi draw a line at 80
> > columns, so that i could see that i am about to hit 80 column limit. I
> > don't want to use word wrap at 80 columns. I want to see the straight
> > line at 80 columns.
>
> It's not the most beautiful way to do it, but one way is to insert a
> line of 80 characters to compare against:
>
> o ESC 80 a x ESC


I am using vim (VIM - Vi IMproved 6.3 (2004 June 7,
compiled Mar 22 2005 23:18:46)
When i gave the above command it gave error message "E319: Sorry, the
command is not available in this version". Any way, thanks for trying
to help me.

Logan Shaw

unread,
Jan 18, 2007, 1:29:57 AM1/18/07
to
wolverine wrote:
> Logan Shaw wrote:
>> wolverine wrote:
>>> Hi,
>>> Is there any way by which i can make vi draw a line at 80
>>> columns, so that i could see that i am about to hit 80 column limit. I
>>> don't want to use word wrap at 80 columns. I want to see the straight
>>> line at 80 columns.
>> It's not the most beautiful way to do it, but one way is to insert a
>> line of 80 characters to compare against:
>>
>> o ESC 80 a x ESC
>
>
> I am using vim (VIM - Vi IMproved 6.3 (2004 June 7,
> compiled Mar 22 2005 23:18:46)
> When i gave the above command it gave error message "E319: Sorry, the
> command is not available in this version". Any way, thanks for trying
> to help me.

I think you must have misunderstood or entered it wrong. I am talking
about entering the letter "o", then hitting the ESCape key, then entering
the digits "8" and "0", then entering the letters "a" and "x", then
hitting the ESCape key again.

It works when I try it in vim 6.2.

- Logan

Thomas Dickey

unread,
Jan 19, 2007, 9:03:38 AM1/19/07
to
Logan Shaw <lshaw-...@austin.rr.com> wrote:

> In some vi-compatible editors, like vim, you can just use control-G to
> see what column you're in, which is a bit easier. Then you just need
> to type "$ G" to see if the line is longer than 80 columns.

iirc, "ruler" was first implemented in elvis (vim and vile do that).
It saves typing ^G's

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

Giorgos Keramidas

unread,
Jan 20, 2007, 10:04:42 PM1/20/07
to
On Fri, 19 Jan 2007 14:03:38 -0000, Thomas Dickey <dic...@saltmine.radix.net> wrote:
>Logan Shaw <lshaw-...@austin.rr.com> wrote:
>> In some vi-compatible editors, like vim, you can just use control-G to
>> see what column you're in, which is a bit easier. Then you just need
>> to type "$ G" to see if the line is longer than 80 columns.
>
> iirc, "ruler" was first implemented in elvis (vim and vile do that).
> It saves typing ^G's

It also works in nvi(1) here, but I'm not sure which vi breed had it
first.

Giorgos Keramidas

unread,
Jan 20, 2007, 10:03:11 PM1/20/07
to

Yep. It should even work in plain /usr/bin/vi in other systems too.

It's pretty much the same 'trick' I'm using when I have to edit the
source code of some script or other program with /usr/bin/vi on Solaris:

o ESC 72 a * ESC

Of course, one can always install vim or Emacs, and turn on their
automatic line-wrapping features, but that's another story :)

- Giorgos

Thomas Dickey

unread,
Jan 21, 2007, 2:27:45 PM1/21/07
to

A good changelog would be nice - nvi seems to lack that.

I only recall having seen it first in the MS-DOS port of elvis in 1992
or 1993, at least a couple of years before encountering nvi. I added it
to vile in August 1993 (according to changelog ;-). I don't have the
email from that time, which would have the discussion regarding elvis.

Anyway, it's a common feature of vi-clones lacking in the "real" vi's.

Geoff Clare

unread,
Jan 22, 2007, 8:48:47 AM1/22/07
to
Thomas Dickey <dic...@saltmine.radix.net> wrote, on Sun, 21 Jan 2007:

>>> iirc, "ruler" was first implemented in elvis (vim and vile do that).
>>> It saves typing ^G's
>
>> It also works in nvi(1) here, but I'm not sure which vi breed had it
>> first.
>
> A good changelog would be nice - nvi seems to lack that.

The file docs/changelog in the nvi 1.79 source distribution has one
mention of "ruler" under 1.34 -> 1.35 Wed Aug 31 19:20:15 1994:

+ Fix ruler to display logical column, not physical column.

> I only recall having seen it first in the MS-DOS port of elvis in 1992
> or 1993, at least a couple of years before encountering nvi. I added it
> to vile in August 1993 (according to changelog ;-). I don't have the
> email from that time, which would have the discussion regarding elvis.

The nvi 1.79 changelog only goes back to Mon Dec 20 19:52:14 EST 1993,
so it is probably safe to assume "ruler" was implemented in nvi before
that (otherwise its addition would be mentioned).

--
Geoff Clare <net...@gclare.org.uk>

Thomas Dickey

unread,
Jan 22, 2007, 1:16:48 PM1/22/07
to
Geoff Clare <ge...@clare.see-my-signature.invalid> wrote:
> Thomas Dickey <dic...@saltmine.radix.net> wrote, on Sun, 21 Jan 2007:

>>>> iirc, "ruler" was first implemented in elvis (vim and vile do that).
>>>> It saves typing ^G's
>>
>>> It also works in nvi(1) here, but I'm not sure which vi breed had it
>>> first.
>>
>> A good changelog would be nice - nvi seems to lack that.

> The file docs/changelog in the nvi 1.79 source distribution has one
> mention of "ruler" under 1.34 -> 1.35 Wed Aug 31 19:20:15 1994:

I see (I was looking at 1.81, hadn't recalled where I had older code).
Looking in 1.76, I see a changelog (same info). But a comment in the
code implies ruler was in "4.4BSD", fwiw.

> + Fix ruler to display logical column, not physical column.

>> I only recall having seen it first in the MS-DOS port of elvis in 1992
>> or 1993, at least a couple of years before encountering nvi. I added it
>> to vile in August 1993 (according to changelog ;-). I don't have the
>> email from that time, which would have the discussion regarding elvis.

> The nvi 1.79 changelog only goes back to Mon Dec 20 19:52:14 EST 1993,
> so it is probably safe to assume "ruler" was implemented in nvi before
> that (otherwise its addition would be mentioned).

I guess neither Steven Kirkendall nor Keith Bostic is reading this
thread...

Thomas Dickey

unread,
Jan 23, 2007, 7:41:47 AM1/23/07
to
Thomas Dickey <dic...@saltmine.radix.net> wrote:
> Geoff Clare <ge...@clare.see-my-signature.invalid> wrote:
>> Thomas Dickey <dic...@saltmine.radix.net> wrote, on Sun, 21 Jan 2007:

>>>>> iirc, "ruler" was first implemented in elvis (vim and vile do that).
>>>>> It saves typing ^G's
>>>
>>>> It also works in nvi(1) here, but I'm not sure which vi breed had it
>>>> first.
>>>
>>> A good changelog would be nice - nvi seems to lack that.

>> The file docs/changelog in the nvi 1.79 source distribution has one
>> mention of "ruler" under 1.34 -> 1.35 Wed Aug 31 19:20:15 1994:

> I see (I was looking at 1.81, hadn't recalled where I had older code).
> Looking in 1.76, I see a changelog (same info). But a comment in the
> code implies ruler was in "4.4BSD", fwiw.

>> + Fix ruler to display logical column, not physical column.

>>> I only recall having seen it first in the MS-DOS port of elvis in 1992
>>> or 1993, at least a couple of years before encountering nvi. I added it
>>> to vile in August 1993 (according to changelog ;-). I don't have the
>>> email from that time, which would have the discussion regarding elvis.

google shows me that elvis added this in version 1.5 (April 2, 1992),
and for reference, version 1.4 was August 4, 1991.

>> The nvi 1.79 changelog only goes back to Mon Dec 20 19:52:14 EST 1993,
>> so it is probably safe to assume "ruler" was implemented in nvi before
>> that (otherwise its addition would be mentioned).

Aside from a few comments that nvi is derived from an early version
of elvis, I don't see anything specific about _when_ that was.
However, comments here (and noting the changelog entry for nvi, which is
the same in the 1.49 tarball).

http://en.wikipedia.org/wiki/Nvi
http://en.wikipedia.org/wiki/USL_v._BSDi

make it seem likely that nvi was derived from elvis 1.5, rather than 1.4

Given a good changelog, one could get the proper information.
(Not specifically aimed at nvi/elvis - this is a problem with many programs).

0 new messages