How to search/replace while including or excluding folded text?

3

2

Is there any way to run a command like:

:%s/tempdir/temp_dir/g

But apply it only to either folded or unfolded code?

KenFar

Posted 2012-08-20T17:27:32.307

Reputation: 163

Answers

3

:folddoopen and :folddoclose do exactly what you want:

:folddoopen s/tempdir/temp_dir/g
:folddoclosed s/tempdir/temp_dir/g

Reference:

:help folding
:help :folddoopen
:help :folddoclosed

romainl

Posted 2012-08-20T17:27:32.307

Reputation: 19 227

Excellent - that's exactly what I needed and somehow couldn't find. – KenFar – 2012-08-21T00:19:04.880