I have used vim for a while, in vim auto-complete, I use 'tab' 'down' to select the next candidate, 'shift+tab' 'up' to select the previous candidate, 'enter' to confirm that completion.
But in Sublime Text 3, I found 'tab' and 'enter' are both to confirm completion, only 'up' 'down' is to select the previous/next candidate.
How can I set the key like vim auto-complete mode ?
Just add this to your keymap:
{
"keys": ["tab"],
"command": "move",
"args": {"by": "lines", "forward": true},
"context": [{"key": "auto_complete_visible"}]
},
{
"keys": ["shift+tab"],
"command": "move",
"args": {"by": "lines", "forward": false},
"context": [{"key": "auto_complete_visible"}]
},
The context auto_complete_visible enables the keybinding only if the autocomplete popup is visible.
Related
how to change the shortcut of auto pep8 in sublime text so it formats the code when i save it.
Default.sublime-keymap
[
{ "keys": ["ctrl+8"], "command": "auto_pep8", "args": {"preview": true} },
{ "keys": ["ctrl+shift+8"], "command": "auto_pep8", "args": {"preview": false} }
]
currently i have to press ctrl+shift+8 i want to change it to ctrl+s but when i try to change it doesn't change. This file is not being edited.
Select Preferences → Key Bindings, which opens a new window with the system default keybindings on the left and the user keybindings on the right. Copy the keybindings from the plugin's .sublime-keymap file into the user file on the right, then alter them as you'd like. Hit save, and they'll be activated.
In this specific case, with your wanting to assign CtrlS, which by default is the "Save" key combo, you should add a context to the keybinding so that it only runs AutoPEP8 on Python files:
{ "keys": ["ctrl+s"],
"command": "auto_pep8",
"args": {"preview": false},
"context": {"key": "selector",
"operator": "equal",
"operand": "source.python",
"match_all": true}
}
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.
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
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 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.