:help /\( let you store what's matched by the pattern inside
\(...\); you can then reference the match (via
\1 for the first group,
\2, and so on) in the replacement (or even afterwards in the pattern itself).
One approach (there are many) to your problem is to capture the filename before the
.tar.gz extension. In the replacement, put the capture (
\1), a space, then the original text (
Alternatively, you can just match the stuff before the extension (ending the match with
\ze), and then duplicate that:
Problems with your attempt
- You used the backreference
\1, but never captured anything.
[a-z_-] does not match a literal
., but this appears in your example.
- No escaping of the final
\.); it would match any character.
- No duplication in the replacement part; you effectively removed text instead of adding.