0

In vim we can move, copy or delete lines from command line

Copy from 12 to 14 code and paste here:

:12,14t.

Move code from lines 14 - 16 to 20:

:14,16m20 

But how to make visual selection from line 10 to 20 from command line?

And a relative question.

How to paste code from external buffer to the line 14, for example?

3
  • What do you mean by "external buffer"?
    – romainl
    Feb 15 at 15:20
  • There's the :{range}read [filename] command to read from a file.
    – Friedrich
    Feb 15 at 15:42
  • 1
    Out of curiosity: what's the use case for creating a visual selection from line numbers? For any operation, the line numbers suffice. Usually, visual mode is employed to (well) visually show the user what they select. I'm under the impression this question turns the concept of visual mode upside down.
    – Friedrich
    Feb 15 at 15:45

1 Answer 1

1

If you mean from Vim command line I would do:

:normal 10GV20G

To past right after line 14 I would do:

:14put
1
  • 2
    :14put (or :14pu, even) would be more straightforward.
    – romainl
    Feb 15 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.