Converting odt to markdown produces \ around special characters. So I need to change \\ to \ and remove if \ is standalone.Sample text:* \[\] match any of the character specified within \[\], use \[^\] to invert the selection* \\W opposite of \\w i.e short cut for \[^a-zA-Z0-9\_\]* \\w match alphabets (both upper & lower cases), numbers and \_ i.e short cut for \[a-zA-Z0-9\_\]Expected output:* [] match any of the character specified within [], use [^] to invert the selection* \W opposite of \w i.e short cut for [^a-zA-Z0-9_]* \w match alphabets (both upper & lower cases), numbers and _ i.e short cut for [a-zA-Z0-9_]On using :% s/\v([^\\])\\([^\\])/\1\2/g I get this:* [\] match any of the character specified within [\], use [^] to invert the selection* \\W opposite of \\w i.e short cut for [^a-zA-Z0-9_\]* \\w match alphabets (both upper & lower cases), numbers and _ i.e short cut for [a-zA-Z0-9_\]So I use the substitution again to take care of sequences like \[\] followed by :% s/\\\\/\\/g to get the desired final output. Is there is a simpler way to do this?
Reduce two consecutive character to just one and remove if that character is standalone
regular expression
This should work::%s/\\\?\zs\\//gHere the first \\\?\zs is used to ignore the first \ if there are two of them. See :h \? and :h \zs for more information.