:su in folded section

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

:su in folded section

Jeremy Conlin
I have a file with portions that have been folded.  Now I want to make
a substitution in my file but exclude the folded portions.  I can
select the lines visually, but when I pass over a folded line(s) they
are also included in this substitution.  How can I avoid making the
changes in the folded region?
Thanks,
Jeremy
Reply | Threaded
Open this post in threaded view
|

Re: :su in folded section

Tim Chase-2
> I have a file with portions that have been folded.  Now I want
> to make a substitution in my file but exclude the folded
> portions.  I can select the lines visually, but when I pass
> over a folded line(s) they are also included in this
> substitution.  How can I avoid making the changes in the
> folded region?

Prefix your :s command with folddoc[losed]

        :folddoc s/foo/bar/g

will change all instances of "foo" to "bar" on any lines that are
not folded (and closed).  It has a counterpart "foldd[oopen]"
that executes a command *just* on the folded sections.

        :help folddoc
        :he folddoopen

HTH,

-tim






Reply | Threaded
Open this post in threaded view
|

Re: :su in folded section

A.J.Mechelynck
Tim Chase wrote:

>> I have a file with portions that have been folded.  Now I want
>> to make a substitution in my file but exclude the folded
>> portions.  I can select the lines visually, but when I pass
>> over a folded line(s) they are also included in this
>> substitution.  How can I avoid making the changes in the
>> folded region?
>
> Prefix your :s command with folddoc[losed]
>
>     :folddoc s/foo/bar/g
>
> will change all instances of "foo" to "bar" on any lines that are not
> folded (and closed).  It has a counterpart "foldd[oopen]" that executes
> a command *just* on the folded sections.
>
>     :help folddoc
>     :he folddoopen
>
> HTH,
>
> -tim


Tim, didn't you get your wires crossed? IIUC foolddoclosed is only for
_closed_ (folded away) folds and vice-versa.

Best regards,
Tony.

Reply | Threaded
Open this post in threaded view
|

Re: :su in folded section

Tim Chase-2
> Tim, didn't you get your wires crossed? IIUC foolddoclosed is
> only for _closed_ (folded away) folds and vice-versa.

gah!  yes, I did.  Jeremy, yes, Tony is right and hopefully you
figured this out, despite my wire-crossing.  At least I pointed
to the germane section of the help :)

-tim