Reputation: 115
I'm trying to yank across multiple lines using '/' search. However I'm only successful at yanking the text that leads up to the search result, not including it.
Example:
//Some Comment
#define SOME_DEFINITION_LALALA 0x0001
I want to select all the text. So with my cursor standing on the first '/' i do y/1
to yank all the text until '1'. However, I want to yank the text including the '1'.
Also, is it possible to do this using 'f'(find) ?
I tried yf1
however I wasn't successful. I can't seem to figure out how to use 'f' across multiple lines.
Thank you!
Upvotes: 2
Views: 541
Reputation: 1254
You can use visual mode to make the selection because then it will be up to and including your search result
v/1<CR>y
It requires only 1 more keypress than your current method and does exactly what you ask. If it does not grab what you want, you can quickly correct it with an additional motion keypress. My typical use would be
v/[search]e<CR>y
Upvotes: 0
Reputation: 195269
you can add an offset e
after your search pattern :
y/1/e<cr>
The yf1
won't work, since your text crossed two lines.
Please check :h search-offset
for details
Upvotes: 6