[TxMt] Hacking Vim mode into TM2

Hans Stimer hans.stimer at gmail.com
Sat Aug 11 17:16:12 UTC 2012


I'm looking for advice on the best way to hack minimal Vim support into TM2. I'm not looking to support all of Vim, but just a subset of what might be referred to as Vim normal mode. 

Desired behavior
===
Until Vim mode is activated, TM2 should behave as normal. Once activated, all the <meta>*-<key> combinations will continue to work as normal TM2 commands, but non-meta key combinations will be interpreted as Vim commands. 

Entering Vim normal mode
---
Traditionally, Vim normal mode is entered via hitting the escape key.  Since most people won't want Vim behavior, there needs to be a toggle that enables Vim so that the escape key will work. This prevents existing TM2 escape behavior changing for those who don't want the optional Vim behavior.

Additionally, it is not uncommon for Vim users to remap the Vim normal mode entry trigger to something like "jj". This should be supported so that users can have the escape key retain it's traditional TM2 use.

Vim normal mode
---
I would like to support the full range of Vim commands for motion, deleting, and changing of text short of entering command mode i.e. ":<command>"


Vim command mode
---
No support, but maybe a subset later.

Vim search mode
---
I don't think this needs support, however it would be handy for '/' to map to opening the find dialog.


Approaches
===
I've spent a little time trying to figure out how to modify TM2 for Vim support and I'm not sure which direction I should go.

1) Hard code it right into TM2. It looks like I could start with OakTextView:keydown and branch off to a Vim interpreter if Vim is enabled. I think this is probably the easiest and most flexible approach. 

2) Create a TM2 plugin/bundle that does most of the work, and modify TM2 just enough to provide the support that such a plugin/bundle would need. This approach worries, me because I'm not sure how much modification TM2 would need to expose all the required interface to the plugin system. Do TM2 plugins work the same as TM1 plugins? Is the TM2 plugin API in flux?

Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20120811/9928ff84/attachment.html>


More information about the textmate mailing list