Fuzzy find within file in Vim

There is "line" extension in the latest Ctrl-P plugin for vim (ctrlp) which can do fuzzy line search. You need to enable the extension manually. Here is my config in .vimrc:

let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlPLastMode'
let g:ctrlp_extensions = ['buffertag', 'tag', 'line', 'dir']

After that you press Ctrl-p to bring menu, then press Ctrl-f several times until the line mode is on. Type your fuzzy string now:

enter image description here

UPDATE 27 Feb 2014

An alternative solution that I'm currently using myself would be to use unite. In order to do fuzzy line search you need to slightly tune unite:

call unite#filters#matcher_default#use(['matcher_fuzzy'])
call unite#filters#sorter_default#use(['sorter_rank'])
call unite#custom#source('file,file/new,buffer,file_rec,line', 'matchers', 'matcher_fuzzy')
nnoremap <C-k> :<C-u>Unite -buffer-name=search -start-insert line<cr>

Now press Ctrl-k and type:

enter image description here

By the way, unite can also do fuzzy file search by name.

UPDATE 03 Aug 2016

Another way to do line search is to use fzf along with accompanying vim plugin. See the installation instructions here: https://github.com/junegunn/fzf.vim#installation

After you have installed both fzf and fzf.vim, you can use :BLines to search lines in the current buffer:

Sample output

You may have noticed it's not exactly fuzzy search meaning that I need to use spaces. This may not work you.

Tags:

Vim