You like emacs, so in .exrc

map ^[q }{!}fmt -72 -s^M}

The ^[ is an escape character, entered with the sequence C-vEsc.
I think that your Meta key will produce one.

C-v produce the character 0x16, used by nvi as <literal-next>, a
character to escape other characters.

The ^M is a <carriage-return>, entered with the sequence C-vEnter,
or C-vC-M.

The } before {!  is to format the next paragraph if we are not
already in one, just like M-q in emacs.

For the whole buffer you can use something like this (as other
pointed before)

map =F %!fmt -72 -s^MG

The % is an abbreviation of "1,$", a range of the whole buffer. There
are some tricky ones like using regular expresions. Ranges aren't
described in the man page.

This is the nvi reference manual. It will be handy:

https://docs.freebsd.org/44doc/usd/13.viref/paper.pdf

When you are playing with maps, remember that a | in a map can be
entered without any escaping if you are using directly the map
command, I mean, you entered ex mode with : and then type map...
If you save the maps with :mkexrc they will be fine. You can write
pipes and they will work, for example. But if you are editing
directly your exrc, they will be treated like ex command separators.
You have to write before a literal <literal-next>, that is the
sequence C-vC-v|

This is not documented anywhere. At least to my knowledge.


And that's my way to say sorry for been an asshole.

adr.

Reply via email to