VSCode's Arrow function auto-complete - visual-studio-code

VSCode's Arrow function auto-complete
Left: VSC, Right: Intellij
Is there an extension that has a function that can automatically complete an anonymous function with the parameter name as shown on the right?
I want it to be auto-completed like IJ in the picture on the right.

Related

TinyMCE Shortcuts - Custom shortcuts appear to be overwriting each other

I've seen a ton of questions about TinyMCE shortcuts, but nothing quite like this.
I have a situation in which I am iterating over an object of shortcuts I want to add to TinyMCE.
The shortcuts add functionality for the greater app around the editor.
For the most part, it works fine.
However, it appears that I cannot add certain combinations. For example, alt+l and alt+left.
Take this code:
_.each(oHotKeyCollection, function (oHotKey, sHotKey) {
this.editor.addShortcut(sHotKey, oHotKey.note, function (e) {
if (!e) {
e = event;
}
// sHotKey is the pattern (ie. alt+l)
alert(sHotKey)
oHotKey.execute(e);
}.bind(this));
}
}.bind(this));
When alt+l is added, and then alt+left is added, hitting alt+l on the keyboard will bring up an alert with alt+left.
Removing the alt+left shortcut allows alt+l to function as expected.
The same behaviour seems to be true of alt+r and alt+right as well as alt+u and alt+up.
How I can get both shortcuts working?
The problem is that only certain keywords can be used in a shortcut, such as the modifier names (ctrl, alt, etc...). Anything else is treated as a single key so left in this case isn't valid and is treated as just being l (see Shortcuts.ts). That's why alt+l is being overridden with your alt+left behavior.
So to fix that, you'll need to use the keycode for left instead of a keyword. In this case that would be alt+37. Here's a fiddle showing that working by printing to the console: https://fiddle.tiny.cloud/EEhaab.
Since you also mentioned you're trying to register other arrow keys, here's the key combinations you'd need to use:
Left: alt+37
Right: alt+39
Up: alt+38
Down: alt+40

How to make IntelliSense show the parameters of a function in VSCode?

How can I make Intellisense show up the function parameters once the parentheses are written down? It shows only if I just type them like in the tutorial example, but not once they are already written and I set the cursor with the mouse inside.
I think you want the Trigger Parameter Hints command. If you type it in the command palette it will show your current short-cut (mine is Ctrl+Shift+Space).

Can I adjust "jump to symbol" in VS Code to "jump to method/function/class"?

I am used to Sublime Text 3 and currently experimenting with Visual Studio Code. In Sublime, I can press Ctrl + R and "goto anything" (prefix "#"). This will only show functions, methods and classes for Python in my case.
In VS Code, I can press Ctrl+shift+o and get "jump to symbol". It is essentially the same list plus many more things which I never need (e.g. import statements, global variables, and parameters of functions). Can I get a similar list as sublime shows, e.g. removing especially function parameters?
Have you tried with Ctrl+T ? And if this don't work you could use the Sublime Text Extension.

How to trigger documentation popup in vscode

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.

Eclipse Content Assist for viewing block declarations from the closing brace?

I'm really curious if anyone knows if Eclipse's Content Assist can be configured to display a code block's declaration by hovering over the block's closing brace (or something similar).
Rather than having to mark long code blocks with a comment, I would much rather hover over the closing brace to view which block it ends.
If what I'm saying isn't clear, imagine you had the code block below:
if (obj instanceof Double)
{
//...PROGRAM LOGIC...
}
In this example, if I were to move the caret to the end brace, right-click the end brace, or simply hover over it. A popup window would show giving me the original declaration at the top:
if (obj instanceof Double) { //...
Also, I'm interested to know if this can be done in Visual Studio; I've asked that question here.
This is nothing to do with content assist.
You can see the block of code as explained below.
Collapse all methods(By pressing Ctrl+Shift+NUM_KEYPAD_DIVIDE. Note you can expand all methods by pressing Ctrl+Shift+NUM_KEYPAD_MULTIPLY)
Hover the mouse cursor towards method collapse icon "+" as shown below.
You will see the content of the method in a popup window. Now press F2 to freez this popup and press ESC to close the popup. Scroll back and forth to see the content. Note that this works for methods, javadocs and import statements only and not for other block statements inside methods and on CLASS body.
Refer How to use Coffee-Bytes code folding for if block folding and try to check the if block content as said above.
Also you can check the scope of block statements by keeping caret after the block start("{") or block end("}") flower brackets and double clicking on it.
See below
You can expand or reduce the block selection by pressing Alt + Shift + Up Arrow and Alt + Shift + Down Arrow respectively and jump to matching bracket(Like "( or )", "{ or }") by keeping caret after the bracket and pressing Ctrl + Shift + P
You mean something like this, when hovering over the closing brace of a code block?
It seems, that this feature has already been implemented and is by default enabled - at least for org.eclipse.jdt.ui_3.9.1.v20140306-2106.
One can enable/disable this text hover (and others) by going to Window/Preferences/Java/Editor/Hovers and selecting the corresponding Source hover. By default the source hover will be activated when pressing "shift" while hovering. When the "Combined Hover" is activated, the source hover should also be automatically be activated without pressing any additional keys.
Note also, that it is quite easy to implement a custom text hover for JDT by writing a plugin and extending the org.eclipse.jdt.ui.javaEditorTextHovers extension point. As an example for how this can be done, have a look at the code of one of the default JDT hovers.