[comp.editors] Vi's

R.Singh@massey.ac.nz (R. Singh) (01/25/91)

This might be a stupid one. How can you get Vi to wrap your sentences around and
insert CR's at the end of each line. I know it is possible to do this literally
but how do you get it to keep the words intact and not cut a sentence in a
middle of a word. For EMACS users, an equivalent of the (auto-text-fill).
Thanx

Raminder $ingh                              Phone : +64 63 69 099 X 7772
Computer Centre MASSEY UNIVERSITY           Fax   : +64 63 505 607
Palmerston North NEWZEALAND                 E-mail: R.Singh@massey.ac.nz

gbastin@x102c.harris-atd.com (Gary Bastin 60293) (01/25/91)

In article <1991Jan24.225511.3375@massey.ac.nz> R.Singh@massey.ac.nz (R. Singh) writes:
>This might be a stupid one. How can you get Vi to wrap your sentences around and
>insert CR's at the end of each line. I know it is possible to do this literally
>but how do you get it to keep the words intact and not cut a sentence in a
>middle of a word. For EMACS users, an equivalent of the (auto-text-fill).
>Thanx

The way I have done it is to include the following two lines in a 
file called .exrc  (ex editor run command file); of course, only the
first line does the wrapping-- the second is a comment so I can remember
how to do it for some other line width :-)   

set wrapmargin=8
" Automatic CR at <= 80 - 8  (72nd) column for vi editor.  

This is very handy to have; it even works for usenet when I fall into
the default editor, which I have set to be vi, of course!  Good Luck!
Gary Bastin, WB4YAF      /-/-/      Internet: gbastin@x102c.ess.harris.com
Mail Stop 102-4826         |        phone: (407) 729-3045
Harris Corporation GASD    |        
P.O.B. 94000, Melbourne FL 32902    Speaking from, but not for, Harris! 

steinbac@hpl-opus.hpl.hp.com (Guenter Steinbach) (01/26/91)

In comp.editors, R.Singh@massey.ac.nz (R. Singh) writes:

> This might be a stupid one. How can you get Vi to wrap your sentences around and
> insert CR's at the end of each line. I know it is possible to do this literally
> but how do you get it to keep the words intact and not cut a sentence in a
> middle of a word. For EMACS users, an equivalent of the (auto-text-fill).
> Thanx

Yeah, looks like you could indeed use that :-)

In vi, try:

:set wm=4

to set the "wrapmargin".  In my vi (HP-UX), whenever wm is set to
anything greater than zero, lines get automatically wrapped at word
boundaries, at least "wm" characters from the right margin.  My normal
setting is 8, which is what I wrote this text under.  I.e. my .exrc
contains

set wrapmargin=8

Actually, my .exrc also contains this:

" S cycles wm=0/8/4, and tells about it
map S *9
map *4 :set wm=4^V|map S *9^M:"wm=4^M
map *8 :set wm=8^V|map S *4^M:"wm=8^M
map *9 :set wm=0^V|map S *8^M:"wm=0^M

which allows me to cycle through wm settings by pressing S.  (Those ^caret-
thingies are control-V and control-M.)

	 Guenter Steinbach		gunter_steinbach@hplabs.hp.com

s887212@minyos.xx.rmit.oz.au (Stephen Riehm [Romulis]) (01/27/91)

R.Singh@massey.ac.nz (R. Singh) writes:

>This might be a stupid one. How can you get Vi to wrap your sentences around and
>insert CR's at the end of each line. I know it is possible to do this literally
>but how do you get it to keep the words intact and not cut a sentence in a
>middle of a word. For EMACS users, an equivalent of the (auto-text-fill).
>Thanx

:set wrapmargin n
will do the trick.. where n is any nnumber >0 (n=1 will wrap 1 character
from the right margin)
another cute trick for this is to pipe paragraphs or the entire file
through fmt like

{!}fmt^M

{ - move to start of paragraph
! - pipe the following text to a program
} - specify the whole paragraph to get piped
fmt - program to pipe paragraph to

hope this helps
catch ya
=========================================================================
Romulis [Stephen Riehm]	         Royal Melbourne Institute of Technology,
					    (124 Latrobe St., Melbourne.)
s887212@minyos.xx.rmit.oz.au				       Australia.

"The PLO, IRA and other _friendly_ organisations claimed responsibility for
the views expressed above last night in press conferences around the world"
-- 
thanx in advance
============================================================================
Romulis [Stephen Riehm]	            Royal Melbourne Institute of Technology,
					       (124 Latrobe St., Melbourne.)

dattier@vpnet.chi.il.us (David W. Tamkin) (02/20/91)

R.Singh@massey.ac.nz (R. Singh) wrote in <1991Jan24.225511.3375@massey.ac.nz>:

| This might be a stupid one.  How can you get Vi to wrap your sentences
| around and insert CR's at the end of each line.  I know it is possible to
| do this literally but how do you get it to keep the words intact and not
| cut a sentence in a middle of a word.

:set wrapmargin to some value greater than zero.

David Tamkin  PO Box 7002  Des Plaines IL  60018-7002  dattier@vpnet.chi.il.us
GEnie:D.W.TAMKIN  CIS:73720,1570  MCIMail:426-1818  708 518 6769  312 693 0591