I want to write a command that replaces all of a line's spaces with figure spaces, and I want the code to not use those literal characters so it is more legible than
:s/ / /g
So, naturally, I try various iterations like:
:s/\x20/\u2007/g " matches a hex char then "20", adds uppercase "2007" :s/\%u20/\%u2007/g :s/[\x20]/\\%u2007/g :s/[\x20]/^Vu2007/g " that's a literal <Ctrl-V> :s/\%u20/\=printf("%c", 0x2007)/g " gives me ^G instead :s/\%u20/\="\<Char-0x2007>"/g " gives me <e2><80><fe>X<87> instead
None of these work, though all of the patterns do indeed match spaces.
I see lots of tricks around for how to enter Unicode characters in Insert mode, but none about how to do so in a replacement string.
In researching this question, I found How to translate Unicode escape sequences to the Unicode character, which gives me the following functional solution:
Is there really no cleaner way to do this? I assume that's unnecessarily costly.