3

Is there any way to copy / paste blocks of text when v is not implemented?`

  • What do you mean not implemented? Do you mean without entering visual mode? – DJMcMayhem Jun 9 '16 at 17:27
  • I mean when you press the v key and it says it isn't implemented. – leeand00 Jun 9 '16 at 17:27
  • @leeand00 are marks available? – muru Jun 9 '16 at 17:28
  • 2
    @DJMcMayhem it's vi – leeand00 Jun 9 '16 at 17:31
  • 2
    I'm working on OpenWRT. – leeand00 Jun 9 '16 at 17:34
5

I downloaded Busybox out of curiosity, and can reproduce the problems you're having with that version of vi. I have version 1.25.0-FRP-441-g53c3b08 2016-05-24 12:20:38 BST.

A large number of vi commands seem to be unimplemented, such as :copy, v, and S. { and } don't seem to work properly.

In terms of yanking, the motions } and / don't work, nor does jumping to marks, e.g. y'a.

f does work, e.g. yfx. More usefully you can use e.g. 2yy to yank a known number of lines. Even better, it looks like you can set two marks with m and then yank between them with with the ex command :'a,'by (yanking from a mark to the cursor doesn't work).

2

In case one uses number mode (enabled with :set nu) and both source and destination of the copy action are visible one can use a ex command:

:<line1>,<line2>t<dest_line>

e.g:

:5,9t17

copies lines 5-9 to line 17.

1

Visual mode is not available in original vi. However, you should still be able to use a numbered yank or marks.

  • In normal mode press #y to yank a block of code (where # is the number of lines you want to yank starting after the cursor's current line). Then you can just use p or P to paste it.
  • In normal mode press ma. This will mark your current position in the file. Then move your cursor to the other end of the section of text you want to yank. Press y'a. This will yank everything between your cursor and the mark "a". Then you can use p or P just like before. Note: You can replace the "a" with any alphabetic character.

Se :h y and :h m for more information.

  • 1
    When I do that and try to paste it says 'nothing in register D' – leeand00 Jun 9 '16 at 17:40
  • That's quite weird. It seems put is trying to use register D for some reason. What happens if you do ""p? (That's TWO double quotes and then a p.) – Tumbler41 Jun 9 '16 at 17:49
1

I have installed vim package and got visual mode

apk add vim

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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