Is there any way to copy / paste blocks of text when v
is not implemented?`
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).
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.
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 usep
orP
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. Pressy'a
. This will yank everything between your cursor and the mark "a". Then you can usep
orP
just like before. Note: You can replace the "a" with any alphabetic character.
Se :h y
and :h m
for more information.
-
1
-
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
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).
-
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 '20 at 13:29
not implemented
? Do you mean without entering visual mode? – James Jun 9 '16 at 17:27