One way to do that:
:s:\(.*//\)\([^/]*\)\(/.*\):\1\2\3 \2:
Explanation:
:s:
- Using substitution
\(.*//\)
- Capture the part up to the double slash (group 1)
\([^/]*\)
- Capture everything that's not a slash (group 2)
\(/.*\)
- Capture the first single slash and everything after it (group 3)
:\1\2\3 \2:
- Output groups 1, 2 and 3 followed by a space and group 2 again
Edit:
You could sorten that to:
:s:\(.*//\)\([^/]*\)\(/.*\):& \2:
The ampersand outputs the whole matched string which includes the whole line since the regex begins and ends with .*
. You could use \0
instead of the ampersand.