Vim: replace only part of a matched regex
There is a number 2 here and a dot there:.
1. but we only want to match 1. not 2
:%s/[[:digit:]]\zs\./:/gc
matches 1. (but 2) and replaces . with : (but the dot after there:.).
%search the whole files/{pattern}/{string}/to substitute a pattern by a string.- :digit: matches a digit.
- backslash the dot to match the dot instead of matching any character
\zsmarks the start of string that should be substitutedgreplaces all occurrences in a linecconfirms each occurrence
Try:
\zeto set the end
personal computing command-line interface (cli) gnu linux trisquel shell literacy wiki vim