FANDOM


Tip 1 Printable Monobook Previous Next

created 2020 · complexity Medium · author Eyal Karni · version 1


Use fuzzy completion to add fuzzing to any ins-mode completion (using <c-x>).

Simply write something in insertmode, wait for completion menu to appear(or trigger it) and use <c-'> to fuzzy search on it.

This requires the fzf.vim plugin[1]

function! PInsert2(item)
	let @z=a:item
	norm "zp
	call feedkeys('a')
endfunction

function! CompleteInf()
	let nl=[]
	let l=complete_info()
	for k in l['items']
		call add(nl, k['word']. ' : ' .k['info'] . ' '. k['menu'] )
	endfor 
	call fzf#vim#complete(fzf#wrap({ 'source': nl,'reducer': { lines -> split(lines[0], '\zs :')[0] },'sink':function('PInsert2')}))
endfunction 

imap <c-'> <CMD>:call CompleteInf()<CR>
  1. ^ https://github.com/junegunn/fzf.vim
Community content is available under CC-BY-SA unless otherwise noted.