Correcting Wrong Marker Folding in VIM
Question
I mistakenly did marker folding to my .vimrc:
{{{8 #CS
something..
}}}8
{{{9 #Math
...
}}}9
... many more!
I need to switch the format to "#SOMETHING {{{NUMBER" like:
#CS {{{8
something..
}}}8
#Math {{{9
...
}}}9
... many more!
What is wrong in the following code:
:%s$/({{{\d/) /(#[:alpha:]/)$\2 \1$g
[Solution]
%s$\({{{\d\) \(#[[:alnum:]]*\)$\2 \1$g
Solution
You forgot to escape the parentheses, and the POSIX character classes are only valid within a character class [[:alpha:]]
:
:%s$/\({{{\d/\) /\(#[[:alpha:]]/\)$\2 \1$g
Note, however, that your example text doesn't contain any slashes - is this what your sample text is actually like?
The above regex changes this
/{{{8/ /#A/
To this
#A/ {{{8/
OTHER TIPS
:%s/{{{\(\d\) \(.*\)/\2 {{{\1/g
it works, but in your regex I don't understand why do you got a $ after s.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow