I am using the keymap to execute the current line in sublime repl by hitting ctrl+enter. The cursor remains on the same line. What do I need to add to the keymap so the cursor would jump to the next line (as what happens in RStudio)?
[
{ "keys": ["ctrl+enter"], "command": "repl_transfer_current", "args": {"scope": "lines"}}
]
I found a way to do it using a python script plugin. Apparently, Sublime by default does not have the option of running multiple commands under a single keymap.
I used the method from here: https://forum.sublimetext.com/t/run-multiple-commands-command/6848
the steps are the following:
Sublime - Tools - Developer - New Plugin
copy code from run_multiple_commands.py found here: https://gist.github.com/bgmort/7ae52ea4270f1c404321c20d1b97733c#file-run_multiple_commands-py
and save the file under the same name as on github: run_multiple_commands.py
Sublime - Preferences - Key Bindings User
code:
{
"keys": ["ctrl+enter"],
"command": "run_multiple_commands",
"args": {
"commands": [
{ "command": "repl_transfer_current", "args": {"scope": "lines"} },
{ "command": "move", "args": {"by": "lines", "forward": true} }
]
}
}
or additionally add [ ] if the file is empty:
[{
"keys": ["ctrl+enter"],
"command": "run_multiple_commands",
"args": {
"commands": [
{ "command": "repl_transfer_current", "args": {"scope": "lines"} },
{ "command": "move", "args": {"by": "lines", "forward": true} }
]
}
}]
Related
I'm looking for a solution to bind ctrl+j, ctrl+i, ctrl+l and ctrl+k to left, up, right, down respectively, but without success.
This is what I've been trying (Key Bindings - User):
[
{ "keys": ["ctrl+j"], "command": "left" },
{ "keys": ["Ctrl+l"], "command": "right" },
{ "keys": ["Ctrl+i"], "command": "up" },
{ "keys": ["Ctrl+k"], "command": "down" }
]
Sublime has been restarted, but with no difference.
Anyone has a solution? Please advice,
Thank you
You're on the right track, but the commands to move the cursor aren't what you think they are. The command you want to use is move, with arguments by and forward to specify which way to move and by how much.
If you open the Sublime console with View > Show Console or by pressing Ctrl+`, you can enter the following command to get Sublime to tell you what command it's executing in response to your actions (run it again with False or restart Sublime to turn the logging off):
sublime.log_commands(True)
If you then press the cursor keys for moving the cursor, you'll see the console telling you what commands are doing the move for you:
command: move {"by": "characters", "forward": false}
command: move {"by": "characters", "forward": true}
command: move {"by": "lines", "forward": false}
command: move {"by": "lines", "forward": true}
This tells you that the command move shifts the cursor around, and that you move by characters to move left and right and by lines to move up and down, with forward describing the direction.
With that knowledge, the key bindings that you want would look more like this:
[
{
"keys": ["ctrl+j"], "command": "move",
"args": {"by": "characters", "forward": false }
},
{
"keys": ["ctrl+l"], "command": "move",
"args": {"by": "characters", "forward": true }
},
{
"keys": ["ctrl+i"], "command": "move",
"args": {"by": "lines", "forward": false}
},
{
"keys": ["ctrl+k"], "command": "move",
"args": {"by": "lines", "forward": true}
},
]
I've been trying to create a shortcut to the snippet palette in Sublime Text 3 but can't seem to get it to work. I don't get an error, I just get nothing. I am on a Mac and have the following in Preferences: Key Bindings - User
{
"keys": [ "ctrl+y" ],
"command": "show_overlay",
"args": {
"overlay": "command_palette",
"text": "Snippet:"
}
}
Did you put your code into this [] ?
It works for me:
[
{
"keys": ["ctrl+y"],
"command": "show_overlay",
"args": {
"overlay": "command_palette",
"text": "Snippet: "
}
}
]
I would like to have ; inserted at the end of line, when I press ;; while in insert mode. What would be mapping for that in sublime-text 3?
Somtehing like:
inoremap ;; <C-o>A;
in VIM.
So far, I managed to get to EOL I am currently on, but have no idea on how to chain other command to insert ;. I was not able to find anything in documentation on running multiple commands in sequence.
{
"keys": [";", ";"],
"command": "move_to", "args": { "to": "eol" }
}
As I wasn't able to find any native-to-editor solution to this,
luckily there is a plugin called Chain of Command
https://packagecontrol.io/packages/Chain%20of%20Command
Then you can put this into user keymap settings file:
{
"keys": [";", ";"],
"command": "chain",
"args": {
"commands": [
[ "move_to", { "to": "eol" }],
[ "insert", { "characters": ";" } ]
]
},
// with a help of this line, command won't get executed
// if in command_mode (vintage mode enabled), so it applies to insert mode
// only.
"context": [ { "key": "setting.command_mode", "operand": false } ]
}
I am using linux [FEDORA 20]. I want to override shortcut key for multiple cursor which is
ctrl+alt+up/down
because it is used for switching workspace in fedora.
I tired to search shortcut in Preferences>key binding - default. But couldn't find it.
So how do i override it?
CtrlAlt↑/↓ is the keyboard shortcut for multiple selection in Windows, not Linux. The following is from the Linux keymap file:
{ "keys": ["alt+shift+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["alt+shift+down"], "command": "select_lines", "args": {"forward": true} },
Go to
Preferences > Key Binding - User and add following lines to override default key bindings.
{ "keys": ["ctrl+space+down"], "command": "select_lines", "args": {"forward": true} },
{ "keys": ["ctrl+space+up"], "command": "select_lines", "args": {"forward": false} }
where
ctrl+space+up/down
is your key bindings.
sublime text 3 Ctrl+Backspace doesn't work
my sublime keymap like this but but still does not work
{ "keys": ["ctrl+backspace"], "command": "delete_word", "args": { "forward": false } },
if it dosen't work for you, you can still make your own shorcut : go to preferences>KeyBendings User and define your own : for example
[
{ "keys": ["f1"], "command": "delete_word", "args": { "forward": false } }
]