In the VSCode "panel" there are the tabs "problems", "output", "terminal", debug console". Within the output tab is a drop-down menu containing many different output views, such as "Tasks", "Extensions", "Git", etc.
I would like to have it make a specific output view visible automatically. For example, when starting a debug session, VSCode may have made the "Adapter Output" view visible, but I'd like to hit a hotkey (or fully automate it) to switch to a different output view.
I'm not certain if this can be done through a task or if it would require an extension, but I cannot find any information on it. Presumably it's possible, though, since VSCode obviously switches panel tabs automatically, and it will make different output views visible depending on the situation.
In this specific case, I'm using the cortex-debug add-on, and SWO text output is sent to an output view during debug sessions. I'm interested in having that output view made visible automatically when I launch the debug session.
Thanks!
Changing the Output View
"So obviously, as you have already mentioned, the way most people switch output views is by opening the drop-down reading the list, until they see the output-view they are looking for, which they then select... Which is slow. Drop downs are counter-productive when attempting to Navigate your Editor quickly. For me, it is easy to see why you want an alternate method for selecting the output's view."
There's a Better way.
For starters your going to need to access, and create custom keybindings. The command hooks are their for you to switch to the outputs you want, but they haven't been added to the default commands yet, and they may not be added ever (which is why you are going to add them now). Below is a simple guide explaining how to make a keybinding in VSCode:
Note: This is part 1 of 2 parts
PART #1
Creating Keybindings
Each Keybinding Has 3 Essential Properties:
key: this describes the pressed keys.
command: Contains the actual command that is to be executed, a limited list can be found in the VSCode Docs. (Click here to see them)
when: This is the when-context, which sets conditional True or False clause which is evaluated upon execution of the command you wrote.
as a reference, this is one of my keybindings I use for disabling ESLint on specific lines where I intentionally break Es-Lints rules.
// ~/.config/Code/User/keybindings.json
// This allows me to pin and unpin editor tabs using the same exact keys
// It is the when clause that makes these keybindings I created possible.
// ctrl+shift+space (& then) ctrl+shift+space (again)
{
"key": "ctrl+shift+space ctrl+shift+space",
"command": "workbench.action.pinEditor",
"when": "!activeEditorIsPinned"
},
{
"key": "ctrl+shift+space ctrl+shift+space",
"command": "workbench.action.unpinEditor",
"when": "activeEditorIsPinned"
},
Note: Sometimes their is an args property.
Moving on...
Part #2
Creating the Keybinding that is Specific to what you want:
Okay so now that you know how, I will give you the clauses, which are slightly hard to locate at first (or at-least they were for me), but once I found them I now always know where to look:
If you drop open the Command-Palette via the [F1] KEY and type "Keyboard Shortcuts", two options for "Keyboard Shortcuts" will popup:
One of the options will read: "Default Keyboard Shortcuts"
The other will simply read: "Keyboard Shortcuts"
They will both open keybindings.json files, but they are two different files in two different locations. The DEFAULT keybindings.json file will be Read-only (its not writable), it is the default keybindings that come with VS-Code. The Default one is important because it contains the long list of commands that can be used when creating keybindings. It is currently the best resource for Keybinding commands anywhere.
The regular keybindings.json file will be empty if you never used it, and this is where you can define your keybindings. To start while focused on the keybindings.json file, hit [Ctrl+k] [Ctrl+k] (twice back to back). An input will pop up where you can define a keybinding, by pressing any keys you want. Once you have defined your keybinding press enter and it will create a preformatted keybinding block for you, it will pre-type the Key Combination you designed as well. In the block enter the When clause you want (you have to figure out when this keybinding is going to be executed, you may or may not be able to leave it blank. A blank "when": "" clause is like telling the editor...
_"This keybinding is to be executed at anytime I use the Key Combination that is associated with it via the key-property".
Last but not least the good stuff:
The output commands:
git.showOutput
notebook.diff.showOutputs
npm-script.showOutput
eslint.showOutputChannel
testing.openOutputPeek
testing.showMostRecentOutput
There may be more, but that's what I was able to find in the Default Keybindings.json file.
Related
I'm trying to add a keyword shortcut that will close all the editors on the right side from the selected one. Somehow this is not by default in vscode on mac (or maybe just to me), I remember using it on window.
Anyway I created the shortcut based on cmd+w closing the selected editor. I thought using cmd + ->(right arrow) w. And it works perfectly for closing the editors. But it conflicts with the existing one cmd + -> that is used to go to the end of the line. How to make both to work.
I don't want to use other keybindings such as a unique one because these keys combination make sense to me. Well I tried also something like cmd+r w. Same problem, there is already a shortcut for cmd+r. And can't use it because it waits for the next key to be added.
There is already a command that does what you want (that is unound by default). Put this into your keybindings.json:
{
"key": "alt+right w", // choose your keybinding
"command": "workbench.action.closeEditorsToTheRight"
}
That's Alt+rightArrow and then a w (or whatever the Alt is on a mac. My guess is that Alt+rightArrow is not bound to anything on a mac.
Since there is no when clause to distinguish this command from Cmd+rightArrow or Cmd+R, using a unique keybinding like alt+right w (option+right w) is as close as you are going to get.
In Sublime (Version 3.2.2, Build 3211) (Ubuntu 18.04.5), I'd like to record a macro where I select-all, copy and paste the current content into another, unsaved file. And then do other commands as well, but I'm not even getting that far. The new-file step doesn't seem to work – neither new, nor new_window, newWindow, new_file, newFile seem to work; not even reopen_last_file. It should be new_file, though.
The console throws this:
Unknown macro command new_file
Which is weird. The command new_file works fine in other contexts: looking at the key-bindings settings, ctrl+n is bound to the same command and the hotkey has no issues.
Selecting all, copying – even this following bit works as intended:
{
"command": "insert",
"args": {"characters": "Hello, Friend!\n"}
}
In their forums, user "jps" writes:
With regards to the other console messages (unknown command, etc), don’t worry about them, they’re supposed to be there :slight_smile:
… but this doesn't seem to be right if it's obviously not working.
I have a project open but closing the project has no effect.
Is there maybe a package or something missing?
Macros in sublime can only capture and replay TextCommand commands; that is, commands that directly modify the content of a buffer or it's visual state. Examples including adding or removing text, changing the selection, moving the cursor around or changing view specific settings (like toggling word wrap or changing rulers, etc).
Commands like new_file, new_window or opening and closing projects are WindowCommand commands, which can't be captured via a macro.
In order to run a sequence of commands that includes a WindowCommand (or ApplicationCommand), you need to use a package. Two examples of that which are readily available on Package Control are Chain of Command and Multicommand.
I'm currently trying to get a shortcut which opens the default and user keybindings in json side by side (pretty much the same what VSCode already provides for the settings.json). Since VSCode does not support that in itself, I tried to do it with the macros extension.
My code looks the following:
"macros": {
"openKeybindings": [
"workbench.action.openDefaultKeybindingsFile",
"workbench.action.openGlobalKeybindingsFile",
"workbench.action.moveEditorToNextGroup",
],
},
I can now trigger this macro with:
{ "key": "ctrl+alt+k", "command": "macros.openKeybindings" },
What I am thinking this macro should be executing is:
Open the default keybindins.json
Open the user keybindins.json
Move the user keybindins.json to a new editor window to the right so they are side by side
My problem now is, the macros does not seem to execute these three commands in sequence. What actually happens if I press ctrl+alt+k is that the default and user keybindings.json get opened in the new editor window to the right.
Can anyone explain to me why the macro does not execute the commands in order and maybe give me a solution to my problem?
Fixed that problem with this issue on the github of this macro
How to trigger a popup with documentation for identifier under the cursor?
Normally it appears when hovering the identifier using the mouse pointer:
I would like to achieve this effect using a command or keyboard shortcut.
The only related commands I found are: trigger completion (which doesn't show the function doc) and trigger parameters hint (which only works when the cursor is inside function call - parameters list).
This is the editor.action.showHover command. It is bound to cmdk cmdi by default.
Note: Shortcut works by holding down the cmd [ctrl in windows], then while holding press k then i
You can change the keyboard shortcut with a keybinding such as:
{
"key": "cmd+k ctrl+space",
"command": "editor.action.showHover",
"when": "editorTextFocus"
}
The default shortcut for Trigger Parameter Hints is Ctrl+Shift+Space
You also have, with VSCode 1.40 (Oct. 2019):
Definition Preview Hover from the keyboard
There is a new command Show Definition Preview Hover for better accessibility of the definition preview hover widget, which can be triggered by hovering a symbol with the mouse and pressing a modifier key dependent on the platform and configuration.
Previously, only the command Show Hover was provided, which is equivalent to hovering the mouse cursor over a symbol.
Now, with Show Definition Preview Hover, the detailed hover information can be shown via the keyboard.
To make this more graphic, check these steps:
In Visual Studio 2019 for Mac, I couldn't find anything about "hover" in the Key Bindings setting. The relevant command seems to be called "Show quick info" and is bound by default to Cmd + F1.
I know this question is about VSCode but I could only find this question when trying to search for an answer. Therefore I would also like to leave the information here in case somebody finds it useful.
There are multiple ways to trigger the documentation popup:
First: Using shortcut ctrl + space
Second: Using vscode extension:
Here is the documentation:
Each answer here demonstrates a different function. Below is a consolidation of every type of helpful popup, the context in which they come up and all the ways I know to trigger them.
These assume default settings.
Function: Display documentation
Shortcut: Ctrlk Ctrli
Scope: Works over named elements - variable and function names (does nothing over literals).
Can display function documentation:
or variable or even property information:
This is the same pop-up you get when you hover over the element briefly.
Function: Display parameter hints.
Shortcut: CtrlShiftSpace
Scope: Works inside a function call.
The cursor must be inside the parenthesis that contain the passed arguments. Does nothing outside that scope.
Can also be triggered by typing a comma, as if passing another argument.
Up/Down arrows can be used to cycle through overloaded definitions (instead of moving the cursor up and down the document).
Function: Display the code completion menu
Shortcut: CtrlSpace
Scope: Anywhere. Will adapt to the context. In strings will display words only. In code will offer symbol hints - function names, variable names within the current scope, known properties, etc.
Is case insensitive.
Matches all contained characters - they do not have to be consecutive (see image above).
Tab or Enter accepts the currently selected suggestion.
Symbol hints can be triggered by just typing letters. Inside strings you must use the keyboard shortcut.
I have searched the Web for this, but with no luck. Any idea?
Thanks.
Try using the Emacs+ plugin available here:
http://www.mulgasoft.com/emacsplus
It provides a HUGE range of functionality - including the selection highlighting that you're looking for - that really helps the move from Emacs. I've only been using it for a couple of days, but it appears stable and integrates very well with the editor.
As described here, you can set emacs key binding to work in component editor in Eclipse
Go to Preferences -> General -> Keys.
Change Scheme to Emacs if you haven't done so already, so you can easily
spot the emacs key bindings.
Sort by Category and look at the "Text Editing" categories
Find the commands that you care about, e.g. Next Column, Previous Column
Select that command and click "Copy Command"
Set the binding to the key by pressing the keys, e.g. press Control-f to
generate "^F".
Change "When:" to "Editing Components".
Repeat for all the key bindings you care about.
So if, in emacs, selection is done by setting the mark (Control-Space) at the start of the region, then moving the point to to the end of the region, you could associate the appropriate shortcut to:
Text Editing > Select Text Start
Text Editing > Select Text End