Re: Formatting Posts With VI

From: Peter Jensen (usenet_at_pekajemaps.homeip.net)
Date: 09/12/04


Date: 12 Sep 2004 08:34:48 GMT


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alan Connor wrote:

> I just stumbled across this little 'trick' and thought it was worth
> passing on.

Let's see, then ...

> What the following allows you to do is to simply hit "v" while you are
> in command mode, and it will re-format the paragraph your cursor is
> currently on, to a maximum line length of 75 characters, splitting and
> filling as it works. (The -c option tells it to leave an indented
> first line alone.)

Do explain why this is better than using 'gq{movement}'.

> (You can change the line length; see man fmt.)
>
> In your ~/.exrc, type the following:
>
> map v {0!}fmt -c^V^V^V^M

Calling an external program to poorly handle what's already built-in,
while at the same time making it impossible to enter Visual mode ... Not
the most clever solution ...

[Snip]

> This is *really* handy if you are writing anything and have to go back
> and add or delete words in a sentence near the beginning of a long
> paragraph. Do the editing, go back to command mode, and hit "v" and 99
> times times out of a 100 the paragraph is okay again. If it isn't
> perfect, only a few keystrokes will fix the problem, compared to the
> tedium of doing the whole thing manually.

Personally I just set the tw variable to 72, enter 'gg}}' to get to the
start of the text, 'gq}' to reformat the first paragraph, and then '.'
to repeat as often as required. Almost every paragraph will be
perfectly reformatted. The remaining can relatively easily be
reformatted manually or with a series of more conservative 'gq<Down>'
commands.

[Followup-To: alt.os.linux]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBRAold1ZThqotgfgRAnUxAJ4nI129Uou0u/mX9v4m3KG7X4kPtQCeLHhQ
okl4zRDMqSlmzAALdw3rSvw=
=h6qB
-----END PGP SIGNATURE-----

-- 
PeKaJe
I AM NOT MY LONG-LOST TWIN, I AM NOT MY LONG-LOST TWIN
	-- Bart Simpson on chalkboard in episode 4F03


Relevant Pages

  • Re: Formatting Posts With VI
    ... > in command mode, and it will re-format the paragraph your cursor is ... > times times out of a 100 the paragraph is okay again. ... start of the text, 'gq}' to reformat the first paragraph, and then '.' ... I AM NOT MY LONG-LOST TWIN, I AM NOT MY LONG-LOST TWIN ...
    (alt.linux)
  • Re: Formatting Posts With VI
    ... > in command mode, and it will re-format the paragraph your cursor is ... > times times out of a 100 the paragraph is okay again. ... start of the text, 'gq}' to reformat the first paragraph, and then '.' ... I AM NOT MY LONG-LOST TWIN, I AM NOT MY LONG-LOST TWIN ...
    (alt.os.linux)
  • Re: Formatting Posts With VI
    ... >>paragraph your cursor is currently on, ... In vim, set cursor to start of paragraph, in command mode, hit gq [down ... format it, rather than the built in formatter, Also, see formatoptions ...
    (comp.os.linux.misc)
  • Re: Formatting Posts With VI
    ... >>paragraph your cursor is currently on, ... In vim, set cursor to start of paragraph, in command mode, hit gq [down ... format it, rather than the built in formatter, Also, see formatoptions ...
    (alt.linux)
  • Re: Formatting Posts With VI
    ... >>paragraph your cursor is currently on, ... In vim, set cursor to start of paragraph, in command mode, hit gq [down ... format it, rather than the built in formatter, Also, see formatoptions ...
    (alt.os.linux)