Sublime text user keymap not overriding default - sublimetext3

I'm using Lubuntu, have changed just one shortcut on sublime user keymap, but nothing that i change there takes any effect.
on default keymap, i have this
{ "keys": ["ctrl+pageup"], "command": "next_view" },
{ "keys": ["ctrl+pagedown"], "command": "prev_view" },
on userkeyma, i replaced it with this:
{ "keys": ["alt+pageup"], "command": "next_view" },
{ "keys": ["alt+pagedown"], "command": "prev_view" },
but it takes no effect whatsoever
this is sublime text 3 build 3083

Related

Is it possible to use C-x C-s for saving in Sublime Text 3

In Sublime Text 3 is it possible to use C-x C-s for saving the file (save_all), while keeping C-s for search option?
ctrl+x+s or ctrl+xctrl+s did not work on my end.
{ "keys": ["ctrl+s"], "command": "find_next", "context":
[{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}]
},
{ "keys": ["ctrl+x"], "command": "noop" },
{ "keys": ["ctrl+x+s"], "command": "save_all" },
{ "keys": ["ctrl+x+ctrl+s"], "command": "save_all" }
Binding key chords like this in Sublime requires you to specify both keys individually in the keys list (that's why it's a list).
So, what you want is:
{ "keys": ["ctrl+s"], "command": "find_next", "context":
[{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}]
},
{ "keys": ["ctrl+x"], "command": "noop" },
{ "keys": ["ctrl+x", "ctrl+s"], "command": "save_all" },
Note that the binding of Ctrl+x to noop is not needed for this to work, so you can leave that out. However using the same key for both single items and in chords like this may require you to hit the key twice to get Sublime to trigger the command, since it otherwise can't tell without some delay which of the bindings you intended.

Sublime text 3, reasign the + and - away from increase decrease font_size to fold unfold

I want to assign the following key bindings (which you set in the user keymap)
{ "keys": ["ctrl+-"], "command": "fold" },
{ "keys": ["ctrl++"], "command": "unfold" }
But the defaults seem to persist which are
{ "keys": ["ctrl++"], "command": "increase_font_size" },
{ "keys": ["ctrl+="], "command": "increase_font_size" },
{ "keys": ["ctrl+keypad_plus"], "command": "increase_font_size" },
{ "keys": ["ctrl+-"], "command": "decrease_font_size" },
{ "keys": ["ctrl+keypad_minus"], "command": "decrease_font_size" },
I would like to remove all zoom effects so i tried this
{ "keys": ["ctrl++"], "command": "null" },
{ "keys": ["ctrl+="], "command": "null" },
{ "keys": ["ctrl+keypad_plus"], "command": "null" },
{ "keys": ["ctrl+-"], "command": "null" },
{ "keys": ["ctrl+keypad_minus"], "command": "null" }
But the keys still zoom the text, what am i doing wrong here?
Maybe if i could just rip them out of the default keymap but that is not editable.
The TL;DR answer to your question is that the reason you're having problems here is that there are more default bindings for the commands that you're trying to run than you've mentioned above (due to some weirdness in Sublime that I don't think I've run across before), and so you're overriding some but not all of the default bindings.
For a longer explanation, we can note that if you use View Package File from the command palette, you can open Default (Linux).sublime-keymap, Default (Windows).sublime-keymap and Default (OSX).sublime-keymap; one of these (based on your question it would appear you're on Windows) is the file that appears in the left hand pane of the key bindings when you use Preferences > Key Bindings, and the other two are for the other platforms supported by Sublime text.
If we search through the default bindings not for the keys that you're trying to redefine, but for the commands that are bound to those keys, we come up with the following:
Windows
{ "keys": ["ctrl++"], "command": "increase_font_size" },
{ "keys": ["ctrl+="], "command": "increase_font_size" },
{ "keys": ["ctrl+keypad_plus"], "command": "increase_font_size" },
{ "keys": ["ctrl+-"], "command": "decrease_font_size" },
{ "keys": ["ctrl+keypad_minus"], "command": "decrease_font_size" },
{ "keys": ["ctrl+equals"], "command": "increase_font_size" },
{ "keys": ["ctrl+shift+equals"], "command": "decrease_font_size" },
{ "keys": ["ctrl+shift+keypad_plus"], "command": "decrease_font_size" },
Linux
{ "keys": ["ctrl++"], "command": "increase_font_size" },
{ "keys": ["ctrl+="], "command": "increase_font_size" },
{ "keys": ["ctrl+-"], "command": "decrease_font_size" },
OSX
{ "keys": ["super+equals"], "command": "increase_font_size" },
{ "keys": ["super+plus"], "command": "increase_font_size" },
{ "keys": ["super+minus"], "command": "decrease_font_size" },
One difference in the bindings seen here is that Windows and Linux use Ctrl for these bindings while MacOS uses Super.
However it's also worth noting a couple of other things as well:
Linux binds the commands to +, - and =
MacOS binds to plus, minus and equals
Windows binds to +, -, =, and equals (plus the keypad equivalents as well)
What's kicking you in the butt here is that Windows also binds the commands using the equals key as seen above, which according to your question you haven't overridden.
There is an internal equivalence between = and equals (as well as the other pairs) that causes Sublime to choose equals over =; you haven't overridden the version of the command that uses equals and thus it still applies.
To truly override the defaults you need to reassign all of the possible bindings for the keys, which would look something like this:
{ "keys": ["ctrl+-"], "command": "fold" },
{ "keys": ["ctrl+="], "command": "unfold" },
{ "keys": ["ctrl++"], "command": "unfold" },
{ "keys": ["ctrl+equals"], "command": "unfold" },
{ "keys": ["ctrl+keypad_plus"], "command": "null" },
{ "keys": ["ctrl+keypad_minus"], "command": "null" },
{ "keys": ["ctrl+shift+equals"], "command": "null" },
{ "keys": ["ctrl+shift+keypad_plus"], "command": "null" },
For completeness this binds ctrl+= and ctrl+equals to the same command, even though only ctrl+equals will always trigger anyway; it's a good reminder that there are multiple keys that do this.
We also bind ctrl++ to that command as well. However this would generally only trigger for keyboards that have a dedicated + key that's not on the numeric keypad (if any).
This is because on the US key layout (which Sublime always uses internally), the + key is the shifted state of the = key; thus you have to press Shift in order to type it, but Sublime seems this as the key ctrl+shift+=; that is, it sees the key and all of it's modifiers, not the shifted state of the key with the ctrl modifier.

How to send cursor to the next line with Sublime keymap

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} }
]
}
}]

how to override shortcut for multiple cursors sublime text 3?

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

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 } }
]

Resources