Cmd2: Fuzzy Search for cmdline

Command-line mode, where you enter commands with : and /, can be enhanced with gelguy's new plugin Cmd2.vim. It gives you fuzzy completion for search, which can be really useful if you've been searching for long strings in overly wordy projects. It also lets you easily get the line number and current word, which I always find fiddly.

Cmd2.vim works by behaving like a new submode -- it's more accurate to think of it as a framework for creating extensions that require command-line input. The fuzzy completion module which most people will want to try is actually an extension built on Cmd2.vim that is bundled with the plugin:

At a higher level, Cmd2 provides a framework to create extensions which require cmdline input. One such extension is Cmd2Complete which provides fuzzy completion for search in wildmenu style. The rendering of the UI and handling of the input is handled by the framework, but can be further customised - for example to create a CtrlP/Unite style menu instead.

The project's readme explains how to create your own mappings and extensions. It doesn't come with default mappings, so you'll need to add the ones you want to use. Don't worry: there's an example of how to add the fuzzy search feature.

I like the idea of extending the behaviour of cmdline, because it's one of those areas where most people don't improve their skills. It's much easier to focus on Normal and Insert mode shortcuts, then just use / as a regular expression execution shortcut.

blog comments powered by Disqus