My default key-bindings for pasting are
{ "keys": ["ctrl+v"], "command": "paste" },
{ "keys": ["ctrl+shift+v"], "command": "paste_and_indent" },
I overrode them in my user key-bindings with
{ "keys": ["alt+k"], "command": "paste" },
{ "keys": ["ctrl+k"], "command": "paste_and_indent" },
I use Dvorak keyboard, which means your V is my K. Also, I want paste_and_indent to be the default.
But Ctrl+k executes paste, not paste_and_indent. I determined this by turning on command logging in the console, with
sublime.log_commands(True)
However, if I make the paste_and_indent command to something else, like Ctrl+Alt+k or Alt+k, it correctly calls paste_and_indent.
I looked through the key-bindings for all of my installed packages, and don't see any other command using Ctrl+k. I also disabled most of my packages except syntaxes. I even accidentally disabled Package Control, but still, Ctrl+k only executes paste.
How can I determine and fix this conflict, so Ctrl+k executes paste_and_indent?
Check out the FindKeyConflicts plugin. There are several options for looking at all key bindings, or just conflicting ones, in a variety of contexts. All the options are available via the Command Palette.
Related
I'm trying to figure out how to make a custom run configuration in Visual Studio Code, and am not succeeding in finding any documentation describing my use case.
I want to make a Run Configuration that runs arbitrary commands that I can set to run my code. This is neccecary because the language I am using doesn't have extensions providing run configurations.
I did find that this is possible with tasks, but I cannot figure out how to run a task by pressing F5 (like you would with a run configuration).
So, this is what I am looking to do: Define something that will run a command (run.exe ${currently selected VSCode file}) when I press F5.
Define this task
{
"label": "Run current",
"type": "shell",
"command": "run.exe ${file}"
}
Redefine the F5 keybinding in keybindings.json
{ "key": "F5", "command": "-workbench.action.debug.start" },
{ "key": "F5", "command": "-workbench.action.debug.continue" },
{
"key": "F5",
"command": "workbench.action.tasks.runTask",
"args": "Run current"
}
In Sublime Text 2 or 3 (I use both, and the answer is probably the same for both), how do you change the hotkey of an installed plugin/package? (on Windows or Linux / Ubuntu)
I already know how to change the key bindings of built-in Sublime commands (Preferences > Key Bindings). For instance, one binding I already have is:
{"keys": ["ctrl+super+b"], "command": "show_panel", "args": {"panel": "output.exec"}}
But in the case of a plugin, how do I know what string to use for "command"? Is there an easy way to find out what the "command" is for an arbitrary function in Sublime?
I would like a general answer that applies to any plugin one could install. Though as an example, today I'm trying to change the hotkey for a plugin called SimpleClone, which has assigned Ctrl+Shift+Right to Split Right. Ctrl+Shift+Right is a rather poor hotkey choice by the maker of the plugin since it already has a use in the operating system: when typing it selects the word to the right. Hence I want to change the assigned key binding.
If plugin has some shortcuts defined, they will be in the *.sublime-keymap files. So if you want to find some shortcut I guess you could grep through all the *.sublime-keymap files in Packages directories, but if you roughly know which plugin uses that shortcut you want to change that shouldn't be necessary :)
For example the Emmet plugin has keybindings defined in: Packages/Emmet/Default (Platform).sublime-keymap.
You can copy the keybinding definitions from these files to your user keybindings file (Packages/User/Default (platform).sublime-keymap) and modify them as you want.
You can open Packages list by pressing Cmd-Shift-P (on Windows should be Ctrl-Shift-P), choosing Package Control: list packages then select the package you neeed and press Enter. Sublime will open package directory where you can find all desired *.sublime-keymap files.
You can do the following:
Go to "Menu->Preferences->Browse packages..."
Find the directory of the interested package.
Find file with ".sublime-commands" extension.
Get command name from file.
Use "Menu->Preferences->Key bindings" for add key binding.
Ex (StringUtilities):
[
{ "keys": ["ctrl+b"], "command": "convert_to_base64" },
{ "keys": ["ctrl+shift+b"], "command": "convert_from_base64" },
{ "keys": ["ctrl+u"], "command": "url_encode" },
{ "keys": ["ctrl+shift+u"], "command": "url_decode" }
]
When I run my macro in sublime text, I get "unable to open:'file path'". The sintax in keymap file is OK, I'm able to save it. This is the key map :
{ "keys": ["ctrl+="], "command": "run_macro_file", "args": {"file": "C:\\Users\\Bane\\AppData\\Roaming\\Sublime Text 3\\Packages\\User\\test.sublime-macro"} },
I'm using win7/64bit.
Your path to the macro file needs to start at the Packages directory, and use Unix-style path delimiters (/). So, your keymap should look like this:
{ "keys": ["ctrl+="], "command": "run_macro_file", "args": {"file": "Packages/User/test.sublime-macro"} },
The paths are designed like this so the Packages directory can be portable, and the same command will work on all three supported operating systems.
How to embed current file path in a custom user keymap? I'm referring to this documentation:
http://sublimetext.info/docs/en/reference/build_systems.html
Which has been deprecated but I do not see equivalent documentation for $file_path variable which I need to use in my keymap in the latest documentation. I'm not having any luck. My keymap looks like this (trying to launch Google Chrome with flag to package my application):
{
"keys": [
"shift+ctrl+g"
],
"command": "exec",
"args": {
"cmd": [
"c:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
"--pack-extension=${file_path}"
]
}
}
The official documentation is here: https://www.sublimetext.com/docs/3/build_systems.html
You may toggle the version switch in the bottom of the sidebar. The $file_path variable still exists though, so it probably should work. You may try removing the wrapping braces { and }
At the moment, I am trying out sublime text. Most of it is fine, but there is one big feature that I can't figure out how to implement in sublime text. In vim, have have space bound to repeat the last macro that I performed. However, I can't find a good way to implement it in sublime text.
In an effort to learn more, I looked at the macro key bindings in the vintage package:
{ "keys": ["q"], "command": "vi_end_record_macro",
"context": [{"key": "setting.command_mode"}, {"key": "is_recording_macro"}]
},
{ "keys": ["#", "<character>"], "command": "vi_replay_macro",
"context": [{"key": "setting.command_mode"}]
},
And (what I think) is the relevant class in the actual plugin:
class ViReplayMacro(sublime_plugin.TextCommand):
def run(self, edit, character):
What I am unable to figure out is how to remember what the last command was, and failing that just have space call the vi macro recorded on 'q'. This means I need to bind vi_replay_macro(q) to space, but I don't understand how the key binding passes which character to replay to the command.
EDIT: I created a plugin that does it.
You would probably have to write your own plugin to run the last macro run. You can try using the command_history method, then search backwards till you find a vi_replay_macro or run_macro command. I'm just making a guess though based on what I know about ST, so there could be other ways to go about it.