On 2009-01-30 07:27 (UTC), Spencer Collyer wrote:

> ----------
> :1,$s/.*/\=printf("mv & sub%03s", line("."))
> ----------
>
> but then I discovered that '&' does not get expanded to the search
> string in functions. Checking the help confirms this fact.

You can use submatch(0) function; it expands to the whole matched text.

    %s/.*/\=printf('mv %s sub%03s', submatch(0), line('.'))

To make it more robust you may want to shellescape() the input filename:

    %s/.*/\=printf('mv %s sub%03s', shellescape(submatch(0)), line('.'))


(Warning: these examples are not actually tested. They should work,
though.)

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to