Reputation: 752
Let's say that I have some text like the one below, and I just want to yank the characters between and including brackets to register "a":
ss = 'Hello World'
a = ['a','b','c']
# this is a comment
b = ['c','d','e']
The best I came up with is (also taking into account this is done within a visual selection):
:'<,'> g/\[.*\]/y A
however this will yank the entire lines.
Upvotes: 0
Views: 429
Reputation: 327
You can use the around syntax. ya[
yanks around including the brackets, and yi[
would yank the insides of it.
Refer to :h text-objects
Upvotes: 4