Multiple actions on one keyboard shortcut in vscode - keyboard-shortcuts

Is it possible to have multiple actions assigned to one keyboard shortcut in visual studio code?
For example:
Move cursor up x 3 set to "ctrl + w"
Thanks in advance.

It's possible with extensions like Commands [Note: Created by the post's author]
settings.json
"commands.commands": {
"down3": {
"sequence": [
"cursorDown",
"cursorDown",
"cursorDown",
],
},
},
keybindings.json
{
"key": "ctrl+w",
"command": "down3",
},
Or with just keybindings.json
{
"key": "ctrl+w",
"command": "commands.run",
"args": [
"cursorDown",
"cursorDown",
"cursorDown"
]
},
Feature request to support Macro like keybindings #871.
Although, for this particular example it's better to use the built-in command (to avoid any jumpiness):
{
"key": "ctrl+w",
"command": "cursorMove",
"args": {
"to": "down",
"by": "line",
"value": 3
}
}
https://code.visualstudio.com/api/references/commands

I use the macros extension:
in settings.json:
"macros": {
"showGit": ["workbench.view.scm", "git-graph.view"]
}
then in keybindings.json:
{
"key": "ctrl+shift+g",
"command": "showGit"
}

Related

VEGA Sunburst highlight current node and parent path

I am trying to highlight node and all linked parents when we hover with a mouse.
So I ask VEGA : " is my datum.currentNode of my arc mark a parent of my currently hovered node ?"
{
"name": "hoveredArcDetail",
"on": [
{"trigger": "hoveredArcIn", "toggle": "hoveredArcIn"},
{"trigger": "hoveredText", "toggle": "hoveredText"}
],
"transform": [
{"type": "flatten", "fields": ["myTreeAncestorList"]},
{
"type": "formula",
"expr": "datum.myTreeAncestorList.currentNodeAndAncestors",
"as": "nodeToCheckIfParentOfCurrentNode"
}
]
},
"fillOpacity": [
{
"test": "indata('hoveredTextDetail','nodeToCheckIfParentOfCurrentNode',datum.currentNodeAndAncestors)||indata('hoveredArcDetail','nodeToCheckIfParentOfCurrentNode',datum.currentNodeAndAncestors)",
"value": 1
},
{
"test": "((isHoveredOnArc==true)||(isHoveredOnText==true))&&!indata('hoveredArcDetail','nodeToCheckIfParentOfCurrentNode',datum.currentNodeAndAncestors)",
"value": 0.5
}
]
Yet the problem is that, when my toggle trigger empties my data when we don't hoover, my transform flatten and formula throws me an error ( as expected ) saying that we cant find such data.
Does anyone have an idea to handle this error ? Thank you !
Full spec is available here
https://vega.github.io/editor/#/gist/ab2b39162b7c3240aa2cbe84d42aa6fb/spec.json
The issue has been solved by setting interactivity for text mark as false:
{
"type": "text",
"from": {
"data": "nodeLabels"
},
"interactive":false

Can't select nth element of same class with xpath / selenium IDE

Don't understand why the following loop doesn't work except for nth element with same class fails on the 2nd element (I'm presuming 1st element works because it's also the root in xpath):
{
"Command": "storeEval",
"Target": "$('.className').length",
"Value": "max"
},
{
"Command": "store",
"Target": "1",
"Value": "i"
},
{
"Command": "while",
"Target": "(${i} < ${max})",
"Value": ""
},
{
"Command": "echo",
"Target": "Current value of i = ${i}",
"Value": "i"
},
{
"Command": "storeAttribute",
"Target": "//a[contains(#class, 'className')][${i}]#href",
"Value": "link"
},
{
"Command": "endWhile",
"Target": "",
"Value": ""
}
For debugging, I tried to change ...[${i}] to [2] and it fails with both Kantu & Ranorex Selocity. However, From my reading of xpath / Selenium IDE documentation, this syntax should be correct. Any advice?
PS. For reference, the .className is actually .rf-project-cover__title on the page https://www.behance.net/search?field=132&content=projects&sort=published_date&time=week
I think you want to search, then extract i-th item, so you need brackets:
(//a[contains(#class, 'className')])[${i}]
for example:
(//a[contains(#class, 'rf-project-cover__title')])[2]
returns item with link text my portfolio

I want tab to insert a tab in Sublime Text but it activates the autocomplete

I am using Sublime CodeIntel which I like for the autocomplete, however it pops up and inserts words while I am trying to insert tabs. I want tab to always insert a tab unless the character before my cursor is a letter.
I reckon this could be done with a user keymap for the tab key to look at context, but I don't know how to do it.
Something like the following should work. You may need to play with the order of the key bindings. Add the following to your user key bindings
{
"keys": ["tab"], "command": "insert", "args": {"characters": "\t" }, "context": [
{ "key": "preceding_text", "operator": "regex_contains", "operand": "[^a-zA-Z]$", "match_all": true }
]
}
Note that I don't have SublimeCodeIntel installed, so unsure how it will behave with that.
As a nice debugging tip, enter sublime.log_commands(True) into the ST console to see what command is being executed for a particular key binding. May be useful in confirming that the command is running as you expect.
A quick work around would be using Autohotkey if you are on windows.
you can assign any keys to 4 spaces like below
`::
Send {Space 4} ; when pressed ` enters four times Space bar
Return
Try this... Overrides tab key to function as indent key and insert tab char only
Preferences > Key Bindings
[
{ "keys": ["tab"], "command": "insert", "args": {"characters": "\t"} },
{ "keys": ["tab"], "command": "reindent", "context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_match", "operand": "^$", "match_all": true },
{ "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true }
]
},
{ "keys": ["tab"], "command": "indent", "context":
[
{ "key": "text", "operator": "regex_contains", "operand": "\n" }
]
},
{ "keys": ["tab"], "command": "next_field", "context":
[
{ "key": "has_next_field", "operator": "equal", "operand": true }
]
}
]

Add shortcut key for multiple plugins in Sublime Text 3

I'm using CodeFormatter and SassBeautify plugins in Sublime Text 3 in order to provide syntax highlighting and formatting for .scss files as well as .js/.html files. I've been able to set up shortcut keys for either plugin, but not to work for both, depending on the type of file I'm in.
[{
"keys": ["ctrl+alt+f"],
"command": "sass_beautify"
}, {
"keys": ["ctrl+alt+f"],
"command": "code_formatter"
}]
Can someone suggest how do to it? I've tried to understand "contexts" but not well enough to do this.
Am I doing this all wrong? Is there another way I should be achieving this?
Corrected keymap file:
[{
"keys": ["ctrl+alt+f"],
"command": "sass_beautify",
"context": [{
"key": "selector",
"operator": "equal",
"operand": "source.scss"
}]
}, {
"keys": ["ctrl+alt+f"],
"command": "code_formatter",
"context": [{
"key": "selector",
"operator": "not_equal",
"operand": "source.scss"
}]
}]
Add something similar to the following as a context entry
{ "key": "selector", "operator": "equal", "operand": "source.scss", "match_all": true }
{ "key": "selector", "operator": "equal", "operand": "(text.html, source.js)", "match_all": true }
The operand values are scope entries. There is a platform specific key binding to display scopes in the status bar, but I don't recall what they are off the top of my head. I personally use https://github.com/facelessuser/ScopeHunter to inspect scopes.

Efficiently bind different keys to the same command

I'm developing a Prolog REPL plugin for SublimeText2. Like the prolog interpreter itself I want to offer multiple different keybindings for the same actions; e.g. one can use both ; and n to dismiss a solution presented by the repl. Currently, to achieve this I just duplicate the keybinding:
{ "keys": [";"], "command": "mycmd", "args": {},
"context":
[
{ "key": "setting.some_setting", "operator": "equal", "operand": true },
{ "key": "replmode_p"}
]
},
{ "keys": ["n"], "command": "mycmd", (etc ...) }
This blows up the size of the keybindings file considerably as many of the definitions are rather large because they only apply to specific contexts. Is there a way to do this without duplicating the bindings, or anything else I can do to optimize this?
Just a quick browse through Preferences->Key Bindings-Default shows multiple entries for the same commands, for example
{ "keys": ["backspace"], "command": "left_delete" },
{ "keys": ["shift+backspace"], "command": "left_delete" },
{ "keys": ["ctrl+shift+backspace"], "command": "left_delete" },
and
{ "keys": ["shift+delete"], "command": "cut" },
{ "keys": ["ctrl+insert"], "command": "copy" },
{ "keys": ["shift+insert"], "command": "paste" },
{ "keys": ["ctrl+x"], "command": "cut" },
{ "keys": ["ctrl+;"], "command": "cut" },
{ "keys": ["ctrl+c"], "command": "copy" },
{ "keys": ["ctrl+v"], "command": "paste" },
just in the first 40 lines (on Windows), so unfortunately I think the answer is no. The only way I could think of doing it,
{ "keys": ["ctrl+k", "ctrl+d"], "command": "find_under_expand_skip" },
maps a double key sequence to the action - hitting CtrlK, then hitting CtrlD runs the command.
Sorry!