Sublime text 2, how to set hotkey to menu items 'View - Word Wrap Column - etc'? - keyboard-shortcuts

I've found solutions on hotkeys Edit - Wrap - etc menu, and View - Word Wrap toggle. But not View - Word Wrap Column - etc menu items. Also tried to find plugins, nothing ...
https://www.sublimetext.com/docs/3/key_bindings.html
Currently there is no compiled list of all built-in commands. The
names of many commands can be found by looking at the Default ({PLATFORM_NAME}).sublime-keymap files in the Default/ package.

If you open the console with Ctrl` and enter
sublime.log_commands(True)
it will print the command for every. single. thing. you. do. Change the True to False to turn it off.
At any rate, for View → Word Wrap Column → 80, for example, it prints
command: set_setting {"setting": "wrap_width", "value": 80}
To set the keyboard shortcut, open your .sublime-keymap file and add the following:
{ "keys": ["ctrl+alt+shift+8"],
"command": "set_setting",
"args": {"setting": "wrap_width", "value": 80}
}
You can of course change the keys to whatever you want.

Related

Shortcut key for selecting a word and extending the selection in VS Code

In VS with Resharper, there's the command ctrlw that will select the whole word at cursor and then, when pressed repeatedly, extend the selection to the brackets, then include them too, then to the next outer brackets etc.
What is the name of the command for that in Visual Studio Code?
The shrink/expand selection commands should be what you are looking for. The command names are editor.action.smartSelect.grow (default keybinding shift+alt+right) and editor.action.smartSelect.shrink (default keybinding shift+alt+left).
i use alt+s for editor.action.smartSelect.grow.
{
"key": "alt+s",
"command": "editor.action.smartSelect.grow",
"when": "editorTextFocus"
}

Configure multiple commands on key combination

In Visual Studio Code, File > Preferences > Keyboard Shortcuts Menu, I can override default bindings in keybindings.json. But how can I add multiple bindings on a key? I wan't to do something like save as well as format code on press of ctrl+s
{ "key": "ctrl+s","command": "workbench.action.files.save,editor.action.format" }
Is this doable?
As far as I know that is currently not possible as the first keyboard shortcut that matches wins (searched from bottom to top) and no further shortcuts are evaluated - from the docs:
When a key is pressed:
the rules are evaluated from bottom to top.
the first rule that matches, both the key and in terms of when, is accepted.
no more rules are processed.
if a rule is found and has a command set, the command is executed.
That said, it seems that someone had the same desire and wrote an extension for that - see gyuha.format-on-save
However I did not test that extension myself so I can't tell you how well it works
Use the when clause as shown here where I hook up ctrl+enter to only case where .py[thon] script editor extension is active which is similar to the ctrl+enter file | preferences | keyboard shortcuts enabled by .R script editor extension.
[
{
"key": "ctrl+enter",
"command": "python.execSelectionInTerminal",
"when": "editorTextFocus && editorLangId == 'python'"
}
]

Short-cut key in VB.NET to take you to the end of the block [duplicate]

I know it's simple to do in C#, but what is the command to jump between If/End If marks in VB.Net like you can jump between braces in C#?
(C#-version of this Question: Go to Matching Brace in Visual Studio?)
If you're using Visual Studio 2010, you can use Ctrl+Shift+Up and Ctrl+Shift+Down to jump between highlighted references and keywords.
Since these are If blocks, the IDE will highlight the Then keyword as well, so just tap Up/Down twice in rapid succession. Up/down wraps, so if you really want to save a keypress, hit the key in the "wrong" direction to get where you want.
I've resorted to putting the opening curly-bracket in a comment just after the THEN and a matching closing curly-bracket in a comment before the EndIf. This is a ghetto way of allowing VI to match the start/end of the block using % keystroke.
A more elegant way would be to use some sort of IDE that understands the block concept in the language you are editing. Sometimes this feature is called a "folding editor" as per http://en.wikipedia.org/wiki/Folding_editor
As I saw else marked when my caret stood at an if (in PHP code), https://google.com/search?q=jump+between+if+and+else+in+vscode brought me here, and patching together various hints led me to the following commands, bound in Visual Studio Code aka VSCode
# Command Palette (⌘+⇧+P # macOS)
Go to Previous Symbol Highlight
Go to Next Symbol Highlight
Reverse engineered default F7 / ⇧+F7 # keybindings.json:
{
"key": "f7",
"command": "editor.action.wordHighlight.next",
"when": "editorTextFocus && hasWordHighlights"
},
{
"key": "shift+f7",
"command": "editor.action.wordHighlight.prev",
"when": "editorTextFocus && hasWordHighlights"
},
To fit the right hand over a numpad keyboard, and having a lot of combinations bound to other commands, my keybindings.json (syntax is .jsonc - JSON with Comments) adds:
{
"key": "ctrl+numpad_subtract",
"command": "editor.action.wordHighlight.prev" // "Go to Previous Symbol Highlight"
},
{
"key": "ctrl+numpad_add",
"command": "editor.action.wordHighlight.next" // "Go to Next Symbol Highlight"
},

How to create a shortcut for user's build system in Sublime Text?

I've just created a build system named XeLaTeX by creating a file named XeLaTeX.sublime-build in the User directory of Sublime Text, whose content is:
{
"cmd": ["xelatex.exe","-synctex=1","-interaction=nonstopmode","$file_base_name"]
}
What should I do, if I want to bind my F1 key to this specific build system?
Note: Ctrl + B, the default build system should not be influenced. That is to say, I could use Ctrl + B to use the default one, and the key F1, the new system, is also available at the same time.
Maybe there is another way to achieve this. Add the following text to Default(Windows).sublime-keymap will execute the command:
{"keys": ["f1"], "command": "exec", "args": {"cmd": ["xelatex.exe","-synctex=1","-interaction=nonstopmode","$file_base_name"]}},
However, $file_base_name is not defined here. Is there any method to pass current file (base_)name to exec?
I nailed it by myself.
AFAIK, there is no such a way to pass current file name through key binding, and it's not possible to use key binding to specify a certain build system. Thus, writing a Python script is of necessity.
There are only three steps.
1. Save the following content to /Data/Package/User/compile_with_xelatex.py:
import sublime, sublime_plugin
class CompileWithXelatexCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.window().run_command('exec', {'cmd': ["xelatex.exe","-synctex=1","-interaction=nonstopmode", self.view.file_name()[:-4]]})
2. Add a line to /Data/Packages/User/Default(<your-plat>).sublime-keymap
{"keys": ["f1"], "command": "compile_with_xelatex"},
3. Open your LaTeX source file with Sublime Text, and then press F1 to compile it with XeLaTeX.
Indeed, it's a little tricky, but it works like a charm for me.
Build systems work by either selecting them specifically in the Tools -> Build System menu, or by using a selector to match a specific syntax. If you want to use a selector, add the following line to your XeLaTeX.sublime-build file (make sure to add a comma , after the first line, the file needs to be valid JSON):
"selector": "text.tex.latex"
The build command is already bound to CtrlB and F7, but if you also want it bound to F1, open Preferences -> Key Bindings-User and add the following line if you already have custom key bindings:
{ "keys": ["f1"], "command": "build" }
If the file is empty, just add opening and closing square brackets [ ] at the beginning and end of the file, respectively, as it also needs to be valid JSON.
Now, whenever you open a LaTeX file, you should be able to hit F1 to build it. If for some reason it doesn't work (if, for example, you have other build systems for LaTeX installed by plugins like LaTeXTools), then just select Tools -> Build Systems -> XeLaTeX, and everything should work properly.
Your example will work, if you give parameter "$file_basename" not "$file_base_name".

Keyboard shortcut for Jumping between "If/End If"

I know it's simple to do in C#, but what is the command to jump between If/End If marks in VB.Net like you can jump between braces in C#?
(C#-version of this Question: Go to Matching Brace in Visual Studio?)
If you're using Visual Studio 2010, you can use Ctrl+Shift+Up and Ctrl+Shift+Down to jump between highlighted references and keywords.
Since these are If blocks, the IDE will highlight the Then keyword as well, so just tap Up/Down twice in rapid succession. Up/down wraps, so if you really want to save a keypress, hit the key in the "wrong" direction to get where you want.
I've resorted to putting the opening curly-bracket in a comment just after the THEN and a matching closing curly-bracket in a comment before the EndIf. This is a ghetto way of allowing VI to match the start/end of the block using % keystroke.
A more elegant way would be to use some sort of IDE that understands the block concept in the language you are editing. Sometimes this feature is called a "folding editor" as per http://en.wikipedia.org/wiki/Folding_editor
As I saw else marked when my caret stood at an if (in PHP code), https://google.com/search?q=jump+between+if+and+else+in+vscode brought me here, and patching together various hints led me to the following commands, bound in Visual Studio Code aka VSCode
# Command Palette (⌘+⇧+P # macOS)
Go to Previous Symbol Highlight
Go to Next Symbol Highlight
Reverse engineered default F7 / ⇧+F7 # keybindings.json:
{
"key": "f7",
"command": "editor.action.wordHighlight.next",
"when": "editorTextFocus && hasWordHighlights"
},
{
"key": "shift+f7",
"command": "editor.action.wordHighlight.prev",
"when": "editorTextFocus && hasWordHighlights"
},
To fit the right hand over a numpad keyboard, and having a lot of combinations bound to other commands, my keybindings.json (syntax is .jsonc - JSON with Comments) adds:
{
"key": "ctrl+numpad_subtract",
"command": "editor.action.wordHighlight.prev" // "Go to Previous Symbol Highlight"
},
{
"key": "ctrl+numpad_add",
"command": "editor.action.wordHighlight.next" // "Go to Next Symbol Highlight"
},