Subject: Re: vi map question
To: Peter Bex <Peter.Bex@student.kun.nl>
From: Robert Elz <kre@munnari.OZ.AU>
Date: 09/25/2003 16:01:45
Date: Wed, 24 Sep 2003 22:45:50 +0200
From: Peter Bex <Peter.Bex@student.kun.nl>
| > :map <key> :/./,/^$/s/^/#/^V^V^V^M
| Thanks a lot, that last mapping is very useful.
It should really be ';' rather than ',' though (it makes a difference
if the current line is a blank line, and so is the next).
| I applied a 0x after it to get
| rid of the pesky extra hash on the last line.
A better way to do that would be to make it be
:map <key> :/./;/^$/-1s/^/#/^V^V^V^M
and never put that "pesky" # on the blank line in the first place.
But then you probably also want a 'j' on the end so the current
line gets to be the blank line.
:map <key> :/./;/^$/-1s/^/#/^V^V^V^Mj
and of course, if you want, it is pretty easy to have it avoid sticking
a '#' into a line that already has one...
:map <key> :/./;/^$/-1s/^[^#]/#&/^V^V^V^M/^$/^V^V^V^M
(there just 'j' doesn't work to find the blank line, as the substitute
would stop at the last line that had no '#' previously).
Now I had better stop before this starts looking as evil as emacs.