How do I keybind SublimeREPL to run Haskell interpeter? - haskell

I've been searching for the right command name to keybind to run Haskell Interpeter in Sublime 3. I'm trying to add to the Sublime key bindings - user and the code should look something like this:
{ "keys": ["alt+keypad2"], "command": "run_existing_window_command", "args":
{
"id": "repl_haskell_run",
"file": "config/Python/Main.sublime-menu"
}
},
The following line is wrong, I made it up and I need to find the right command to put there:
"id": "repl_haskell_run",
"file": "config/Python/Main.sublime-menu"

I think the following does what you are looking for. I found the command by looking for a .sublime-menu file in the Haskell folder of the SublimeREPL repo: config/Haskell/Default.sublime-commands. (One such file had to exist for you to be able to do ctrl + shift + p -> SublimeREPL: Haskell.)
[
{ "keys": ["alt+keypad2"],
"command": "run_existing_window_command",
"args": { "id": "repl_haskell", "file": "config/Haskell/Main.sublime-menu" } },
]

Related

Keybinding alt+up won't work in Sublime Text 3

I want to copy the Move Line Up/Down keyboard shortcut of VS Code to Sublime Text 3 which uses Ctrl+Up/Ctrl+Down key bindings, so I placed the following in the User-defined key-bindings file:
[
{
"keys": ["alt+up"], "command": "swap_line_up",
"keys": ["alt+down"], "command": "swap_line_down"
}
]
The swap_line_down works but the swap_line_up doesn't. I've already checked for conflicts within Default(Windows).sublime-keymap. I've tried to swap the commands to check if the problem is specific with alt+up
[
{
"keys": ["alt+up"], "command": "swap_line_down",
"keys": ["alt+down"], "command": "swap_line_up"
}
]
and, indeed, now swap_line_up works but swap_line_down doesn't. So it seems alt+up is the problem. What seems to be the issue here?
Your key bindings aren't specified correctly; each binding object should have a single keys and command (and optionally a single args and context key s well), but you have both specified in a single binding.
It should look more like this:
[
{
"keys": ["alt+up"], "command": "swap_line_up",
},
{
"keys": ["alt+down"], "command": "swap_line_down"
},
]

how to bind multiple key to a command in sublime

In sublime, for example,I want to bind both ctrl+1 and ctrl+2 to a command, is there any way to set this?
Thanks.
You can simply repeat the config. For example:
[
{ "keys": ["super+ctrl+f"], "command": "toggle_full_screen" },
{ "keys": ["super+alt+f"], "command": "toggle_full_screen" }
]
Will result in both super+ctrl+f and super+alt+f working.
Note the , at the end of the lines except the last line if you're getting syntax errors.
Don't confuse it with using a pair of shortcuts for a single command, which is done like this:
{ "keys": ["super+k", "super+b"], "command": "toggle_side_bar" },

Hotkey for running command

I want to create a keyboard shortcut in Sublime Text 3.
The command I want to run is something like this:
[make.sublime-build]
{
"name": "boot-dev-svr",
"cmd": ["java","-jar","D:\\prg\\boot\\boot-1.1.1.jar","development"],
"working_dir": "D:/smx",
"path": "C:/Windows/System32",
}
The key I want to map this action to is F5:
[Default (Windows).sublime-keymap - User]
[
{ "keys": ["f5"], "command": "BLAH BLAH BLAH" },
]
Seems like it should be simple, but "cmd" and "command" seem to be fundamentally different. I have not managed to get it to work.
How do I put these things together to do what I want in Sublime Text 3?
Have you tried putting the actual command in []
That worked for me.
Another solution would be to update Sublime Text 3 to the latest release, sometimes that fixes the bug.
Hope I helped!
EDIT
Try removing the comma from the end of make.subime-build, like this
{
"name": "boot-dev-svr",
"cmd": ["java","-jar","D:\\prg\\boot\\boot-1.1.1.jar","development"],
"working_dir": "D:/smx",
"path": "C:/Windows/System32",
}
This is what I wound up doing, which seems to work, more or less.
Build:
{
"cmd": ["python","prj.py","--runmake","serve"],
"working_dir": "D:/smx",
"path": "C:/Python27",
"variants":
[
{
"name": "boot-dev-svr",
"cmd": ["java","-jar","D:\\prg\\boot\\boot-1.1.1.jar","development"],
"working_dir": "D:/smx",
"path": "C:/Windows/System32",
},
]
}
Keymap:
[
{ "keys": ["f5"], "command": "build", "args": {"variant": "boot-dev-svr"} },
]

Sublime text: how to add a key binding to hex_viewer package command

I've installed the Hex Viewer package on sublime text 3, to toggle it i use ctrl+shift+p to open the command palette, then i search for "hex" and select the command of the package to toggle the hex view.
I was wondering how to bind a key to the specific package command, I'm aware of the key bindings configuration file but I don't know what JSON line should I add to call the package command.
This is my first question on stackoverflow, sorry if I did something wrong, have a nice day!
EDIT: This is the github of the package: https://github.com/facelessuser/HexViewer
It says:
There are 10 commands available via the command palette or by key-bindings.
This is the one I should like to bind
Hex Viewer: Toggle Hex View
And this is the string I've tried to paste on the key-bindings JSON file:
{"keys":["ctrl+shift+h"] , "command":"Hex Viewer: Toggle Hex View"}
You need to add a key binding for the Hex Viewer keymap.
To do this, after installing Hex Viewer via Package Control, navigate to Package Settings -> Hex Viewer -> Key Bindings - Default and add the following:
[
{
"keys": ["ctrl+shift+h"],
"command": "hex_viewer"
}
]
To save the file, you need to ensure that the %APPDATA%\Sublime Text 3\Packages\HexViewer directory exists, assuming this is your package directory.
There's also an example key map available on the GitHub link you mentioned with the other available commands.
Example.sublime-keymap
[
{
"keys": ["ctrl+shift+b","ctrl+shift+h"],
"command": "hex_viewer"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+i"],
"command": "hex_show_inspector"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+f"],
"command": "hex_finder"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+e"],
"command": "hex_editor"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+x"],
"command": "hex_writer"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+u"],
"command": "hex_discard_edits"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+="],
"command": "hex_checksum",
"args": {"panel": true}
},
{
"keys": ["ctrl+shift+b","ctrl+shift+-"],
"command": "hash_selection"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+g"],
"command": "hash_eval"
}
]
Your binding should be
{ "keys": ["ctrl+shift+h"] , "command":"hex_viewer"}
you could use something like this to assign a key biding to a plugin
-> Preference -> key - bending - user
then add this
[
{ "keys": ["ctrl+shift+x"], "command": "the name of plugin." }
]

Sublime Text 2 config - Let space save the file

Sublime Text 2 already supports normal Vim bindings. However, I'd like to have it support saving the current file when pressing space in command mode.
This key binding has become one of my number one features I love about vim.
However, when trying to write this key binding, Sublime Text 2 seems to ignore it:
{ "keys": ["space"], "command": "save",
"context":
[
{ "key": "setting.command_mode", "operand": true }
]
}
Sublime Text 2 seems to not recognize "space".
It much rather has to be like this:
{ "keys": [" "], "command": "save",
"context":
[
{ "key": "setting.command_mode" }
]
}

Resources