Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The fine answers already point interesting solutions, but here's another one, making use of the <code>\zs</code>, which marks the start of the match. In this pattern:</p> <pre><code>/[0-9]\zs / </code></pre> <p>The searched text is <code>/[0-9] /</code>, but only the space counts as a match. Note that you can use the class <code>\d</code> to simplify the digit character class, so the following command shall work for your needs:</p> <pre><code>:s/\d\d\zs /, /g ; matches only the space, replace by `, ' </code></pre> <p>You said you have multiple lines and these changes are only to certain lines. You can either visually select the lines to be changed or use the <code>:global</code> command, which searches for lines matching a pattern and applies a command to them. Now you'd need to build an expression to match the lines to be changed in a less precise as possible way. If the lines that begins with optional spaces, a <code>[</code> and two digits are the only lines to be matched and no other ones, then this would work for you:</p> <pre><code>:g/\s*[\d\d/s/\d\d\zs /, /g </code></pre> <p>Check the help for <a href="http://vimdoc.sourceforge.net/htmldoc/pattern.html" rel="nofollow"><em>pattern.txt</em></a> for <code>\ze</code> and similar and <a href="http://vimdoc.sourceforge.net/htmldoc/repeat.html#%3aglobal" rel="nofollow"><code>:global</code></a>.</p> <hr> <p><em>Homework: use the help to understand <code>\zs</code> and see how this works:</em></p> <pre><code>:s/\d\d\zs\ze /,/g </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload