EDIT Actually junegunn already has everything covered for you. Since you already use fzf you can add this to your vimrc
:
imap <c-x><c-l> <plug>(fzf-complete-line)
And now <c-x><c-l>
will use fzf to fuzzy match your line against the existing one in your buffers and complete directly in your buffer.
See fzf's readme for the list of available completion functions.
One way to do it would to be leverage the :Lines
function provided by fzf. This is probably a bit overkill if you don't already have the plugin in your workflow but if you, do you could add this mapping to your vimrc:
nnoremap <leader>i :execute('Lines ' . expand('<cWORD>'))<CR>
The mapping calls the Lines
command with the WORD under your cursor as argument (see :h <cWORD>
and :h execute()
)
Then when you are in normal mode and your cursor is on Button
you can use <leader>i
(or any key you'll use in your mapping) and this will show this kind of window with the list of the lines in the open buffers matching the word under your cursor.
Fzf provides two related commands which could be useful here:
You could also make something using only built-in vim features but that requires a bit more work. A starting point would probably be to read :h 'grepprg'
.