Is it possible to execute bash string manipulations to the filename of the current file, represented by %
in external commands from within vim?
Example:
I am editing a file myfile.txt
. Using :! command %
, I can execute a command
on myfile.txt
from within vim. For instance, to copy myfile.txt
to myfile.ext
(simply change the extension), I can write :! cp % myfile.ext
. But there is some redundancy, and I'd like to deduce myfile.ext
from %
(and avoid writing myfile
).
In bash, if the name myfile.txt
is contained in the variable $var
, I can write cp $var ${var%txt}ext
for instance.
Is there a way to mimick this in vim? Of course, I cannot write :! cp % ${%%txt}ext
... though it is what I'd like to be able to!