patkar@cb.ecn.purdue.edu (The Silent Killer) (02/07/88)
>There has been a problem I have had with formatting paragraphs in >vi: the definition using "}" seems to be "up to the next empty line", >but when editing *roff files I only want to format up to the next >line containing a dot command. > >So, how do I easily tell vi to stop where desired? You can put the following line in your .exrc. map /^\. Then you can just type to format the paragraph. This macro will search for a dot at the beginning of a line, mark it as 'a, go back to the original position and format till the marked line. >Robert J. Drabek Anant patkar
patkar@cb.ecn.purdue.edu (The Silent Killer) (02/07/88)
Correction: Apparently the character ctrl-A was eaten by 'postnews'. This is what the map command should read map ctrl-A (the rest of the stuff) Then you can type ctrl-A for the required result. Anant Patkar.
hansm@cwi.nl (Hans Mulder) (02/09/88)
In article <215@cb.ecn.purdue.edu> patkar@cb.ecn.purdue.edu (The Silent Killer) writes: >In article <???> Robert J. Drabek writes: > >>There has been a problem I have had with formatting paragraphs in >>vi: the definition using "}" seems to be "up to the next empty line", >>but when editing *roff files I only want to format up to the next >>line containing a dot command. Actually, "}" stops at the end of the paragraph, which can be an empty line or an .IP, .LP, .PP, .QP, .P, .LI or .bp request (when using *roff) (This is the default. Put a `set paragraphs=whatever' line in your .exrc file if you don't like it.) >> >>So, how do I easily tell vi to stop where desired? > > > You can put the following line in your .exrc. > >map /^\. This line was either scrambled by some mailer, or it contains non-printing characters. I suppose it should have read map g /^\.^Mma''!'afmt^M Here ^M stands for a ctrl-M character which you enter into your file by typing <ctrl-V><ctrl-M>. This defines the `g' command as `run the buffer between the current line and the next line beginning with a dot (inclusive) through the `fmt' command'. > >>Robert J. Drabek > >Anant patkar Actually, you don't need to mark anyhting. Simply define: map g !/^\.^Mfmt^M This does the same without the marking business. The point is that the `!' command (and others, like c, d, s, <, > ) takes as its first argument a move-type command, and / is a move command. So you can do things like `d/foo' or `>/end'. P.S. I believe the manual forgets to mention that your .exrc file is not read if you have defined an EXINIT evironment variable. So, if you already have an EXINIT variable, add your `map' commands to it, rather than producing an .exrc file. Hope this helps, Hans Mulder