Sublime Forum

Capture all keystrokes in command_mode (ala Vim)

#1

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:

   {
      "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?

0 Likes

#2

Good to know.

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

Ta,
-ash

0 Likes

#3

proof of concept: 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: 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.

0 Likes