Question

I'd like to copy current line in vim editor to some different places. Is there a way to do it with one command?

The following is impossible command illustrating what I mean.

:t 25, 28, 54

Of course I can do it with

:t 25
:t 29
:t 56

However I'd prefer make it with the only command.

Was it helpful?

Solution

You can get it using pipe to concatenate commands:

:t 25 | t 28 | t 54

OTHER TIPS

For something like that, you need a custom command, e.g. this:

:command! -nargs=+ T for lnum in reverse([<f-args>]) | exe 'copy' lnum | endfor

Invoke it via :T 25 28 54.

By processing the arguments from last to first, this avoids adapting the line numbers for the added lines.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top