I use Vim with marker folding for my work and the presence of all the fold markers annoys my colleagues, so I want a quick and easy way to cleanly remove them all from my files. Closing markers are easy, as I make sure they are always on their own line, preceded by varying amount of whitespace, so
:%s/^\s*# }}}\n//g
works fine.
Opening markers are a bit more of a problem as they can take one of two forms, either at the end of a comment (eg # IMPORTS {{{
) or at the end of a block definition (eg def fn(): # {{{
). I can deal with these two individually with
:%s/ {{{//g
:%s/ # {{{/g
but when I try to combine the two, I cannot get it to work. I have tried
:%s/( | # ){{{)\\g
:%s/( # {{{| {{{)\\g
both with and without an initial '^.*' before the parentheses but it didn't work (yes, I know that would have deleted the entire line, but I was hoping it would at least point me in the right direction). I've even tried escaping the various # and { characters out of sheer desperation, not expecting that to work since they don't need escaping in the individual substitutions, but regardless of what I try, all I get is a 'pattern not found' error. I've tried Googling, with no luck - all the answers I've found seem to say I'm doing it right, but I'm obviously misunderstanding them
It's not a major hassle having to use three instructions, especially as I plan to put this into a function, but I just want to know, what is the correct method of searching for and deleting either of the two patterns in one go?
:s/files/workplace/
:-)