Optional Emulated Command Bar for Vim (searching only so far)

Review Request #109867 - Created April 5, 2013 and submitted

Simon St James
A bit of a monster, I'm afraid ;)

As I mentioned on my blog (http://kate-editor.org/2013/03/16/kate-vim-mode-papercuts-bonus-emscripten-qt-stuff/) I'm not really a fan of the current integration of Vim with Kate's built in Find/ Replace dialog, so I started working on a more Vim-ish replacement.  Here is the initial stab at it - there's still plenty of work to do, but searching with "/" and "?" already works better than before, plus we have shortcuts like ctrl-r, etc.

Currently, it's off by default, and switched on by a (hidden) config option: *ideally*, I'd like to make it the default and only choice (and then clean some of the Vim-specific stuff out of the Kate Find/ Replace dialog), but I'd like to blog and get some feedback, first.

The advantages of this patch are:

a) Less buggy interaction of searches with "n" and "N" (case-insensitivity in particular);
b) More Vim-style shortcuts: dismiss via ctrl-c, ctrl-[ etc; backspace via ctrl-h & dismiss via ctrl-h when empty; ctrl-r for insertion of register contents/ word under cursor in document; etc.
c) More Vim-ish cursor placement - the cursor always stays at the first character of the match;
d) The total match so far is highlighted, as in Vim (dismissed when the bar is closed). Search is SmartCase, incremental, and wraps around;
e) Can be used from mappings;
f) Can be used with the (eventual!) Vim macro implementation.

Still a lot of fine-tuning left, but it would be nice to get this committed before doing so.  Some plans:

a) Get ctrl-w to work right: it's currently really stupid;
b) Eventually get the bar to replace ":" - this will be great for extensibility, as the fact that it works with mappings means that we'll be able to trigger complex Javascript expressions with a couple of keypresses;
c) Go through history with ctrl-n/ ctrl-p : I'm going to extend Vim's implementation and make it context-sensitive, so if we do a ":s/blah/something/ and the cursor is on "blah", then we'll move through the history of search terms; if on "something", we'll go through the history of replace terms; etc.  Usage of "*" and "#" will of course add to the history;
b) A few more extensions: toggle regex vs literal with some shortcut; delete and place cursor at "blah" and "something" in the above with shortcut(s); etc
d) Vim-style interactive search and replace;
e) Escape the search term to be more in line with Vim's ("(" and ")" should be treated as literals, for example, not regex commands);
f) ... and a bunch of other stuff ;)

After that, it will be on to macro support!

Some dogfooding, and an extensive battery of automated tests.


Dominik Haumann
Simon St James
Christoph Cullmann
Commit Hook
Simon St James
Review request changed

Status: Closed (submitted)