Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I love using the Command-T plugin in Vim to do fuzzy searches for filenames. I like it so much that I've started to want to do the same fuzzy searches for arbitrary strings within an open buffer.

For example, if I'm editing a CSS file that contains a selector like #support-main .question .answer-rating, I can currently type /support-main .question to find that line.

I'd like to be able to invoke a fuzzy finder and simply type something like supmaique to find that same line (among others). I know I can type /sup.*mai.*que for the same effect but typing the .*'s breaks my concentration.

Is there a way to do this?

share|improve this question

2 Answers

up vote 1 down vote accepted

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: http://i.stack.imgur.com/w8MWV.jpg

share|improve this answer

Not exactly what you want, but with set incsearch your pattern is matched as you type. It's not really fuzzy matching but the feeling is sort of similar.

share|improve this answer
Ah, yes. incsearch is great, but not what I'm looking for. – adamesque Feb 15 '12 at 17:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.