Web lists-archives.com

Re: text editors




On 25.03.19 04:38, mick crane wrote:
> Is there any text editor, preferably in a terminal that has the facility to
> protect lines in the document, not the document itself ?
> I've got 2 blocks of "code" that look similar and I keep editing the wrong
> one and then it doesn't work.

The only thing I can think of, using vim (haven't used anything else for
30 years), is to turn on folding, and include a warning in a comment on
the first line of the block. Whether folding is on blank lines (simple
paragraph/block folding), or foldmethod=marker, the first line line is
displayed while folded.

Having to unfold the block, with only the warning and a short initial
line of code or block identifier visible, ought to be sufficiently
alerting if the blood level in the caffeine stream is not too high.

Putting the warning in "foldtext" wouldn't work, because then it'd
appear on all folded paragraphs - unless you used foldmethod=manual, and
only folded the troublesome blocks.

In extremis, you could write a vimscript function to do all sorts of
weird stuff on folding, but I think it would be a bit of work to put a
password on unfolding.

:help folding

Erik