Tag Archives: Key Mapping

Kate Vim Mode: Papercuts (+ bonus emscripten-qt stuff!)

:)

I was a long time Vim holdout and often wondered to myself, “just why do those nutheads use vim?” until I googled and read the blog I just linked. After trying Vim out for a few days, I was completely hooked, but didn’t want to leave KDevelop with its awesome Intellisense/ code completion/ navigation features. Thankfully, Kate has a Vim mode, so I could get the best of both worlds

However, I’d often run into small but jarring inconsistencies with Vim, or sometimes find missing features, and so I set about trying to fix as many as I could. Since these were usually very small and unimportant things, I’ll just go ahead and list them, Graesslin-style :)

Vim mode is one of those rare and happy pieces of code which you can very easily write tests for: just add the starting text; the list of keypresses; and the expected, final text. Kuzmich Svyatoslav wrote a big battery of them a while back, and my first ever patch was an incredibly trivial little one that fixed a hole in the test framework and a bug that the hole obscured.

After that, I:

  • Improved the test framework to enable us to test Insert Mode features;
  • Fixed the inner curly bracket text object to be more like Vim (rather than deleting everything between the curly braces on a diB, Vim usually attempts to leave the closing curly bracket on its own line);
  • Added { and } motions to Visual Mode;
  • Fix a few bugs with Erlend’s very handy “comma text object” extension;
  • Fixed numerous bugs with t/T and , & ; involving them getting “stuck” behind occurrences of the character to search for, and also made them “counted” so that one can do e.g. 3ta, and also mirroring Vim’s behaviour where if we can’t find the required count of characters on the line, we don’t move at all;
  • Stopped the transition from Visual Mode to Normal mode from resetting the cursor position if we exited via ESC or Ctrl-c;
  • Fixed a bug with the nifty “block append” feature;
  • Fixed a nice bug with replaying the last command via . when the last command was an insertion that had a Ctrl-o in the middle of it (all the characters after we exited the Ctrl-o were treated as commands, with predictably zany results!)
  • Ensured that the bracket text object worked in Visual Mode;
  • Made the very handy Key Mapping feature “counted”, so you could perform your chosen Mapping several times in a row, and also made them count as one edit that could be reverted with just one request to Undo;
  • Made p & P move the cursor to the end of the pasted text instead of leaving it at the beginning (whoops!), and similarly for gp/gP which places the cursor one past the end, hopefully respecting Vim’s slightly obscure exceptions and corner cases (e.g. p and P act as gp and gp when in Temporary …read more
    Source: FULL ARTICLE at Planet KDE