TinyMCE Shortcuts - Custom shortcuts appear to be overwriting each other - tinymce

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

Related

Trying to recognize Fn + V on my keyboard

I hate that when I'm using my laptop on its own I often type FN+v when I mean to paste. So I decided to solve my problem with AHK. I installed a keyboard hook in my main script,and used that to extract the fn keys value, 163. My initial test worked, but adding the & to make it a modifier does not. What am I overlooking?
So this doesn't work
SC163 & v::
MsgBox, %A_ThisHotkey% was pressed.
return
but this did work
SC163::
MsgBox, %A_ThisHotkey% was pressed.
return
When you hit the FN key, it might be remapping the "v" to something else (like "Media_Play_Pause" button) in the keyboard driver. Therefore the key code wouldn't be SC163 & v but something like SC159.
The Special Keys section for mentions a method to get the Scan code:
Ensure that at least one script is running that is using the keyboard hook. You can tell if a script has the keyboard hook by opening its main window and selecting "View->Key history" from the menu bar.
Double-click that script's tray icon to open its main window.
Press one of the "mystery keys" on your keyboard.
Select the menu item "View->Key history"
Scroll down to the bottom of the page. Somewhere near the bottom are the key-down and key-up events for your key. NOTE: Some keys do not generate events and thus will not be visible here. If this is the case, you cannot directly make that particular key a hotkey because your keyboard driver or hardware handles it at a level too low for AutoHotkey to access. For possible solutions, see Special Keys.
If your key is detectable, make a note of the 3-digit hexadecimal value in the second column of the list (e.g. 159).

Autohotkey: remap ctrl + {

I want ctrl + { to work as the home key.
This doesn't work:
^{::Send {Home}
I guess the { needs to be escaped?
This also doesn't work: (it generates an error on loading the script)
^{{}::Send {Home}
What is the correct way of doing this?
You can use the steps listed here to find the scan code and virtual key code of the { and then use either of those (SCnnn or VKnn) in the hotkey definition.
Even though that works I was curious why the ^{ doesn't work for your layout, so I tried using it and seeing if AHK's key history showed {, which it does. I took a look at AHK's source code to see what's happening, and I think it comes down to the return value of VkKeyScanEx called with { and your layout, which is 0x0634, i.e., AltGr+4. I hadn't noticed that AltGr+4, AltGr+5, and AltGr+9 all produce { in your layout before this, so I tried the ^{ hotkey again and sure enough it fires with AltGr+4. So it seems it's just a limitation of VkKeyScanEx: even if multiple combinations map to some character only one of them can be returned. In your .klc file, wherever LEFT CURLY BRACKET first appears will be the combination that VkKeyScanEx returns. I don't know if you use the AltGr combinations for {, but if you remove them from your layout the ^{ hotkey should work for just Ctrl+{.

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.

View All Eclipse shortcuts

I was trying to learn all the eclipse shortcuts... I couldn't find anything useful.
There are some shortcuts available for easy ones, like Find, Find in Files, Comment, Uncomment etc.
Is there any way to view all the eclipse shortcuts?
Clicking Ctrl+Shift+L from eclipse, will list all the shortcuts. This is pretty useful, as you don't need to switch to another window... You can do your work without any interruption.. :-)
Open Windows->Preferences->General->Keys. Now you can use the filter to find your shortcut and change its binding.
CTRL + SHIFT + L
Shows you a list of your currently defined shortcut keys.
However this will only show you custom short cuts that user have added therefore, Please find useful eclipse short-cuts below
CTRL + /
In line Comment
CTRL + SHIFT + /
Block Comment
CTRL + D
Delete row. Try it! You no longer need to grab the mouse and select the line, or select Home, Shift + End, Delete. Quick and clean.
ALT + Up/Down Arrow
Move the row (or the entire selection) up or down. Very useful when rearranging code. You can even select more rows and move them all at once. Notice, that it will be always correctly indented.
ALT + Left/Right Arrow
Move to the last location you edited. Imagine you just created a class "Foo", and now you are working on a class "Boo". Now, if you need to look at the "Foo" class, just press Alt+Left Arrow. Alt+Right Arrow brings you back to "Boo".
CTRL+SHIFT+O
Organize imports. What happens when you first use a class you have not yet imported? You will see an error. But when you press this magical combination, all your missing classes will be imported, and the unused imports will vanish.
CTRL+1
Probably the most useful one. It activates the quick fix. Imagine you create a class, which implements some interface. You will get an error, because the inherited methods are not yet implemented. While you are on line where the error occurs, press this combination to activate the quick fix. Now, select the "Add unimplemented methods" option. You can use the quick fix at every error you ever receive.
Quick fix comes in handy in other situations too. My favorite is the "Split variable declaration". Sometimes I need to broaden the scope of a variable. I activate the quick fix, split declaration, and use alt + arrow to put it where it belongs. You can find even more uses: Convert local variable to field, rename in file, inline local variable, etc...
You could use the "Split variable declaration" on the bar variable, and then move it with Alt+Arrows above the try block..
Or you could use the "Add unimplemented methods" fix here.
The best thing you can do if you see an error is to use the quick fix.
CTRL+SHIFT+T
Open Type. Imagine, that you need to have a look at the "Foo" class. But, where is the "Foo" class? Is it in the "Boo" project and in the "foo.bar" package? Or somewhere else? With this shortcut, you don't need to know. Just press it, type "Foo" and you are in.
CTRL+E
Shows you a list of all open editors.
CTRL+F6
Use to move between open editors. This is a slower alternative to Ctrl + E. It comes in handy in a situation when you want to periodically switch between two editors, something that is nearly impossible with Ctrl+E as it sorts entries quite randomly. Or you might just use Alt+Arrows...
CTRL+F7
Move between views. When in the editor, press Ctrl+F7 to switch to the Package Explorer, or hold Ctrl and press F7 multiple times to switch to other views.
CTRL+F8
Move between perspectives. The same as the previous.
CTRL + F11
Runs the application. What gets launched depends on your settings. It will either launch the last launched class (my preferred way) or it will launch the currently selected resource (the default way). If you want to change its behavior read the previous post.
CTL + N
Open new type wizard. This is not very quick because you have to select the wizard type (whether you want to create new class, jsp, xml or something else) in the next step. A much faster way would be if you could just hit the shortcut and invoke the particular wizard. It is possible, just keep reading...
CTRL + M
Maximize or umaximize current tab.
CTRL + I
Corrects indentation.
CTRL + SHIFT + F
Formats code. You can make beautiful looking code out of a mess with this. It requires a bit of setup, but it is well worth it. You can find its settings under Window->Preferences->Java->Code style->Formatter
CTRL + J
Incremental search. Similar to the search in firefox, it shows you results as you type. Don't be surprised if when you hit this combination nothing happens - at the first glance. Just start typing and eclipse will move your cursor to the first occurence.
CTRL+SHIFT+G
Bind this to "Generate getters and setters". This is a "must have".
ALT+C
Bind this to SVN/CVS "Commit".
ALT+U
Bind this to SVN/CVS "Update".
yes, you can go Window - Preferencee - General - Keys and see all available shortcuts. Also you can reorder keys here.
Also you can read more about eclipse shortcuts here