Sublime Forum

Calling other keybinding from a keybinding

#1

I don’t think that this can be done, but I thought I’d ask… Is it possible?

This can be easily worked around by defining a plugin/macro that does the exact steps you want, but I think it’d be nice to be able to define macrokeybindings out of several other keybindings. I don’t know whether I’m making any sense here… In my head it all seems to work. :wink:

0 Likes

#2

[quote=“guillermooo”]I don’t think that this can be done, but I thought I’d ask… Is it possible?

This can be easily worked around by defining a plugin/macro that does the exact steps you want, but I think it’d be nice to be able to define macrokeybindings out of several other keybindings. I don’t know whether I’m making any sense here… In my head it all seems to work. :wink:[/quote]

heh? makes no sense to me :confused: explain a lil better please.

0 Likes

#3

Such as pressing F10 would translate into pressing F4, F5, and F6 in sequence?

I don’t think it can be done… create a macro! They’re a sequence of commands instead of a sequence of keys.

Besides, if you were to change what F5 did, your macrokeybinding wouldn’t work anymore…

0 Likes

#4

In sublime no, in autohotkey yes…

Just create a hotkey binding when sublime is current active window and done :smile:

I do this a lot and combining autohotkey + sublime is just pure heaven :smiley: there’s no limits lol…
Examples, I wanted to zoom in/out with mouse wheel, but sublime doesn’t allow mousewheel keybindings so? autohotkey ftw!

;========================================================= ;SUBLIME ZOOMIN / ZOOMOUT ;========================================================= ;Ctrl + Mousewheel up ~^~WheelUp:: IfWinActive, ahk_class SKMainWindowClass Send !{=} return ;Ctrl + Mousewheel down ~^~WheelDown:: IfWinActive, ahk_class SKMainWindowClass Send !{-} return

To do what gpfsmurf said you would do this…

~F10:: IfWinActive, ahk_class SKMainWindowClass Send {F4}{F5}{F6} return

Btw if you are wondering why the “~” is there so it doesn’t cancel out the hotkey functionality in any other program :smile:
so F10 would work normally in any other program but when in sublime it will send F4,F5,F6

Another one which one member requested which is a good example is “Triple-Click-to-SElect-Lines”, obviously thru sublime api is impossible to do this (at least atm) but with autohotkey is very possible like I posted the script.

My recommendation, use autohotkey + sublime = happy camper :smile:

0 Likes

#5

EJ12N, quick question about AutoHotkey…

This is what I use for mousewheel zooming; it looks different from your script:

#IfWinActive ahk_class SKMainWindowClass ; Sublime Text ^WheelUp::SendInput ^{=} ; ZoomIn ^WheelDown::SendInput ^{-} ; ZoomOut #IfWinActive

Do you know if it makes an actual difference?

0 Likes

#6

Not at all. In fact that is the recommended way to go :smile: with the #ifwinactive
ex: the triple click script.

[code];#IfWinActive, ahk_class SKMainWindowClass
;~*LButton::
;{
; if clickCount > 0
; {
; clickCount += 1
; return
; }
; clickCount = 1
; SetTimer, clickHandler, 400
; return

; clickHandler:
; SetTimer, clickHandler, off
; if clickCount = 3
; {
; ;Triple click detected, send Ctrl+L shortcut to select the line…
; SendEvent, ^l
; }
; clickCount = 0
; return
;}
;#IfWinActive[/code]

0 Likes

#7

I think I got ahead of my self. The fact that you can assign commands by name to keybindings defeats the whole purpose of my suggestion.

AutoHotkey’s a nice app, though. Thanks!

0 Likes