Home Download Buy Blog Forum Support

Capture all keystrokes in command_mode (ala Vim)

Capture all keystrokes in command_mode (ala Vim)

Postby ashb on Thu Jun 02, 2011 9:56 pm

So I'm quite taken with ST2 but I just can't get around the lack of vim bindings - I'm too used to all the complex motions you do without having to hit modifier chords. For example - replace everything inside the current "string" would be: escape ->T ->" -> c -> t -> "

So I'm taking a bash at implementing a vim behaviour. Thanks to someone on this forum getting into and out of command mode was easy. The problem now comes in implementing some of the commands.

Lets take this example: 2d3w (it deletes 6 words via a round about fashion: do_twice -> delete( motion = words(3) ) )

It is theoretically possible to do this with many different contexts and combinations in the keymap, but the idea of doing that isn't something that appeals to me. So what I was hopping I could do is something like this:

Code: Select all
   {
      "keys": "everything",
      "command": "vim_mode", "args": { "key": "$0" },
      "context": [ { "key": "setting.command_mode", "operator": "equal", "operand": true } ]
   }


i.e. just have my plugin function called for every keystroke that happens in command mode.

Thoughts? Just plain not possible right now?
ashb
 
Posts: 8
Joined: Thu Jun 02, 2011 9:29 pm

Re: Capture all keystrokes in command_mode (ala Vim)

Postby ashb on Fri Jun 03, 2011 3:19 pm

Good to know.

Is there any where I can add my vote to that too? (User echo?)

Ta,
-ash
ashb
 
Posts: 8
Joined: Thu Jun 02, 2011 9:29 pm

Re: Capture all keystrokes in command_mode (ala Vim)

Postby lunixbochs on Thu Jun 09, 2011 1:50 am

proof of concept: https://github.com/lunixbochs/sublimevim

I have a WIP command plugin infrastructure so commands will be handled intelligently instead of hardcoded as they are now

for keybindings, I'm just hardcoding for lack of a good api... though I do use a class generator here to save code: https://github.com/lunixbochs/sublimevi ... im.py#L652

it's actually pretty usable, supports command+insert mode, hooks letter+number keys, and supports a few commands, ([dyc][dycbe], a, i, o, O, u, U, p, P...) shows how : and / might work (: works for absolute and relative line movement and basic saving/quitting, / works for forward search)... has insert, replace, command modes. one of the commands screws up sublime's builtin undo and crashes the whole thing when you undo via ctrl+z so I wouldn't call it ready for 100% use, though I coded most of it with itself active.
lunixbochs
 
Posts: 91
Joined: Fri Oct 08, 2010 10:18 pm


Return to Plugin Development

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests