Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-- is there a way to copy up to a search term, _including_ the term?

Tags:

vim

copy-paste

If I have the following words

cat Oliver Louis

and the cursor is on "c", I can copy up to the beginning of Louis with y/Louis<CR> (where "CR" is the enter key), which will copy the string "cat Oliver ".

Is there a way to copy the search term, "Louis", as well, for a copied string of "cat Oliver Louis"? Thanks in advance.

like image 460
gatoatigrado Avatar asked Dec 12 '22 20:12

gatoatigrado


1 Answers

Use the /e modifier: y/Louis/e<CR>. If you want to repeat the last search pattern, just leave it out: y//e<CR>.

:help search-offset
like image 151
too much php Avatar answered Feb 23 '23 10:02

too much php