4

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? – James 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
6

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).

| improve this answer | |
4

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.

| improve this answer | |
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.

| improve this answer | |
  • 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

| improve this answer | |
0

This is old question but I found this for the same reason as the OP (that I'm using openwrt), so I thought I would give the specific answer for that case.

The issue is that in OpenWRT by default vim is aliased to vi. You can check this by doing: alias vim.
That is set inside /etc/shinit (which is sourced at boot) and contains the following line:

[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi

This basically says if /usr/bin/vim is not present create the alias. The problem is if you install vim e.g. opkg install vim-full, the behaviour doesn't immediately revert and so vi is still launched when vim is run.

To fix this, you can run unalias vim or reboot (and the alias won't be created).

| improve this answer | |
  • Welcome to Vi and Vim and thanks for your contribution! Also note that you don't have to reboot, but just log out and back in to have the shell initialization executed again. – filbranden Jun 7 at 13:29

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.