gbergman@ucbtopaz.CC.Berkeley.ARPA (10/28/84)
Item <262@lzmi.UUCP> suggests typing ^V^V^V^M into the map command to make it "place a literal ^M into the file". This it will, but I believe that what the author of <308@digi-g.UUCP> wanted was not a ^M within the troff file, but simply several lines of text, and for this one should type ^V^M into the map command. I agree with a later comment, that several lines of troff input that are used repeatedly should be made into a macro; still, here are two useful examples of how to use vi commands to insert newlines. In each case, I will show ^M where one types in ^V^M (equivalently, ^V<CR>) since a simple ^M is what you see on the screen: to make function-key 1 start a new paragraph: :map! #1 ^M.PP^M to double-space a (non-n/troff) text file: :%s/$/^M Warning: I believe that embedded ^M's in vi commands only work with versions 3.7 and higher of vi. <623@gloria.UUCP> gives macros such as .if n \{ . ds d0 \u.\d . ds d1 \u*\d . ds d2 \u**\d . ds d3 \u***\d . ds d4 \u****\d\} This has two bugs: first, the line .if n \{ will, if the condition "n" holds (i.e. if you are nroffing rather than troffing) insert a blank line into the text. To avoid this use .if n \{. Second, when the line . ds d4 \u****\d\} is processed, the character "\}" will be included in the string definition. This can have several effects. The most likely to be serious is that if the string \*(d4 is included in a conditional input where the condition is unsatisfied, it will terminate the condition prematurely. E.g. if you include in your text a note .if \n(yr>89 \{Items marked \(d4 are likely to be out of date.\} Then until 1990 this will give the unintended output "likely to be out of date." Further in a .tm line, the internal form of \}, which is ^^, is output unprocessed. Since adm3a's and tvi's interpret ^^ as "home to the upper left-hand corner of the screen", it can mess output to the screen. (In ditroff \} is ^Q; I don't know whether that can cause any trouble.) Finally, it can be translated to a genuine output character. So if for some unlikely reason you set up the translation line .tr \}\(bs your \*(d4 will be peculiar indeed. The solution to this problem is to replace the above line by the two lines . ds d4 \u****\d .\} Finally, item <20141@wivax.UUCP> gives a macro that includes lines such as .if !'\\$1'' \\$1 to output argument 1 if it is nonempty. The trouble is that if argument 1 contains the delimiter-character "'", the ".if" condition will be confused. Anyway, why worry about empty arguments? Why not just use .if \\n(.$>0 \\$1 and allow the user to include empty arguments as "" if for some reason s/he wants to input an empty line? The .$= trick is intriguing nonetheless; I may eventually start using it... . George Bergman Math, UC Berkeley 94720 USA ...!ucbvax!gbergman%cartan