简体   繁体   中英

Sublime Text Xdebug Start Debugging (Launch Browser) custom keybinding

I am wondering how to set a custom keybinding for Sublime Text using xdebug to start debugging with launching the browser. This is my .sublime-keymap file I am using. I tried adding the last key binding to start debugging while launching the browser, but it doesn't work

[
    { "keys": ["alt+shift+f"], "command": "reindent" , "args": { "single_line": false } },
    { "keys": ["ctrl+enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line Before.sublime-macro"} },
    { "keys": ["ctrl+alt+s"], "command": "prompt_save_as" },
    { "keys": ["ctrl+shift+s"], "command": "save_all" },
    { "keys": ["ctrl+m", "ctrl+o"], "command": "fold_by_level", "args": {"level": 2} },
    { "keys": ["ctrl+alt+f5"], "command": "Start Debugging (Launch Browser)"},
]

There is a key binding for the regular start debugging, which is ctrl+shift+f9, but I want to be able to start the browser because the bug I need to find is when a certain thing happens in my web app.

Any help would be appreciated.

The simple way to solve this problem is adding argument launch_browser to xdebug_session_start , like these:

{"keys": ["ctrl+shift+f9"], "command": "xdebug_session_start", "args": {"launch_browser" : true}},

It would be Ok.

the resolve is from: http://www.mattkirwan.com/programming-tools/2015/10/22/customising-sublime-text-xdebug-shortcuts.html

I assume you're using Xdebug Client , as this is the only xdebug package available for Sublime Text 3. If you look at the other keymaps, you'll notice that the "command" is snake_case , so "Start Debugging (Launch Browser)" won't work as a command. To find the command needed, go to the Github repo and check out the Default.sublime-keymap file, which lists all the default key bindings and their associated commands:

[
    {"keys": ["ctrl+f8"], "command": "xdebug_breakpoint"},
    {"keys": ["shift+f8"], "command": "xdebug_conditional_breakpoint"},
    {"keys": ["ctrl+shift+f5"], "command": "xdebug_continue", "args": {"command": "run"}},
    {"keys": ["ctrl+shift+f6"], "command": "xdebug_continue", "args": {"command": "step_over"}},
    {"keys": ["ctrl+shift+f7"], "command": "xdebug_continue", "args": {"command": "step_into"}},
    {"keys": ["ctrl+shift+f8"], "command": "xdebug_continue", "args": {"command": "step_out"}},
    {"keys": ["ctrl+shift+f9"], "command": "xdebug_session_start"},
    {"keys": ["ctrl+shift+f10"], "command": "xdebug_session_stop"},
    {"keys": ["ctrl+shift+f11"], "command": "xdebug_layout", "args": {"keymap" : true}}
]

Ctrl Alt F9 is bound to the "xdebug_session_start" command, so just enter that in your user .sublime-keymap file and you should be all set. However, you should also note that Ctrl Alt F5 already has a command mapped to it, so you'll need to make the decision of whether you want to override that command, or pick a different key binding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM