Reputation: 6050
I have a dictionary in my config file.
candidates = {'morpheus':(3,1), 'trinity':(3,1), 'neo':(3,1), 'switch':(3,1)}
I can highlight with my mouse one k/v pair (e.g. 'neo':(3,1)
) to copy and paste if I needed add more k/v pairs to the dictionary but is there a way using vi keyboard commands to yank from the current cursor to the next comma or space to grab the 'neo':(3,1)
k/v pair?
I know there's yw
for yank word but in this case, vi stops at the punctuation marks and doesn't grab what I want. I think I can also yank characters to the left or right of the cursor but I don't want to count characters if I can help it.
Is there a way to tell vi to yank from the current cursor position to the next space or the next )
character?
Upvotes: 0
Views: 360
Reputation: 196476
yw
, which is actually "yank to next word" rather than "yank word", is not to be taken as a single command. It really is two commands: an operator, y
, followed by a motion, w
. This is pretty important because understanding that operator+motion model allows you to freely compose very expressive editing commands.
In this case, you can move the cursor to the closing )
with f)
or 2t,
, which gives you the two following commands:
yf)
y2t,
See :help f
, :help t
, and the user manual's introduction of the operator+motion model: :help 04.1
.
Upvotes: 2
Reputation: 3087
Yank to the next space (excluding space) yt
(Note the space at the end, the character yanking to)
Yank to the second space (excluding space) y2t
Yank to the next space (including space) yf
Yank to end of line y$
Yank everything inside of current '...'
yi'
Upvotes: 1