I want to change all lines in a file with zero or one space at the end to end with exactly two spaces (to force line breaks when the file is parsed with markdown).
I've done it in Sublime Text with the following find and replace regexes:
Find: (\S)[ ]?\n
Replace: \1 \n
But out of interest, I wanted to try and do the same substitution in vim.
I tried the above but it found no matches. So I tried
:%s/\(\S\)[ ]\?\n/\1 \n/g
and it places weird characters all through the file.
On its own, /\(\S\)[ ]\?\n
finds all the correct line endings.