My Problem
I am editing a markdown file with some links in a [link text](url)
format.
Some of these links lack a space after the closing parens, e.g.:
...fit the [Single Responsibility Principle](https://link...)and can ...
Which renders to a missing space after the link:
...fit the Single Responsibility Principleand can ...
I am trying to build a regex search-replace to add a missing space after the closing parens where necessary.
What have I (naively) tried
Tried search-replacing with a regex:
%s#\)(\S)#\) (\1)#gc
%s#\) - Closing parens
%s#\)(\S) - Followed by a non-space
%s#\)(\S)# - Replaced with...
%s#\)(\S)#\) - The closing parens followed by a space
%s#\)(\S)#\) (\1)#gc - And the original character
And, of course, Googled the problem.
My question
How can I add a space after every closing parens that has a non-space character just after it?
:help q
) might offer an alternative approach which work well if you are just looking for a one-shot/"not going to need this fix again" solution. In this case I would record the commands that fix the space and go to the next)
. Then at each occurence of)
I would either use the recorded commands or skip to the next)
character (with a simple search for)
).