From: Tim Chase <[EMAIL PROTECTED]> Subject: Re: Hiding lines Date: Sun, 17 Sep 2006 11:15:13 -0500
> > One could hide lines matching or !matching a certain pattern. Any > > further edit actions were only executed with the visible lines as > > target. Regardless what you were doing -- only the visible lines were > > affected. You had to give the "unhide" command explicitely to return > > to "full text mode". > > > > There is a script snipped in the VimTips (#77) which does something > > like this, but the "hidden" lines are not protected or "really > > invisible until unhide"... > > > > Is there a way to mimic this feature with vim in any way ? > > Well, while it sounds like you may have already uncovered folding > (which will collapse/hide a bunch of lines into one), but as you > describe, it doesn't really protect those lines. However, there > are some things you can do do make them a little more protected. > If you're doing :s commands (or other Ex commands), you can > have them operate only over things that aren't currently folded > away by modifying your Ex statement to be: > > :foldd s/foo/bar/g > > You can read all about folding at > > :help fold.txt > > wherein you'll find > > :help folddoopen > :help folddoclosed > > which allow you to perform operations over sections of the file > that are/aren't folded. > > You don't really describe what "protected" means...so perhaps if > there are particular things that stymie you, you can mention them > and perhaps a solution can be found for the particular problems. > > If you just want to extract certain lines, you can make use of a > :g command, something like > > :let @a='' > :g/pattern/y A > > will gather all the lines matching "pattern" into the "a" > register. This can be dumped in another buffer if needed. > > Or, I often find myself doing something like > > :g/pattern/# > > which will show me all the line numbers in the current file for > lines matching "pattern" (after which I can just jump to that > line by typing the line-number followed by "G"). > > Just a couple ideas... > > -tim > Hi Tim, thank you for your explanations ! :O) With "protected" I mean the effect of doing as follows (but I mean the result only ... not the way which leads to it...) There is a text with some lines containing the word "gold". Those lines should never be changed/edited. Therefore I will do a :g/gold/d Then I will do all commands, mistakes or whatever, which I will do -- all "gold" lines will not be affected. After all that I will do a "undo delete of all lines containing 'gold'" -- and that's it. In reality an "undo delete all lines containing /pattern/" is not pratical, impossible, irritationg or whatelse. This is only as an example for "being protected". An Unix "chmod a-w" on all lines matching /pattern/ cames a little closer to it -- unless you are root, hehehehe.... But in the last example those lines were not hidden. Examples are only ...examples, therefore... Hope my german English is english enough... ;) Keep hacking! mcc