Use Keyboard Maestro to move the cursor one space forward - keyboard-maestro

In ST3 (OS X) I use shift+space to move the cursor one space forward, i.e. with something like:
{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": true} },
I find myself wanting to use this in other applications too. I thought I could use Keyboard Maestro to write a macro that did this, but haven't got very far. Any suggestions?

In Keyboard Maestro there is a 'Simulate Keystroke' action that you could use to do that.
Create a new macro, triggered by 'Hot Key Trigger', and set your hot key.
Add a new action, 'Simulate Keystroke', and set the keystroke.
Here's a screenshot of the test macro I made:

Related

Can VS Code input text when I type a rapid shift shift sequence?

So, my new keyboard doesn't have the pipe key, and I use it frequently (I'm learning elixir right now). I know that alt + 124 produces |, but it is a bit annoying to type it every time I want to use |> on elixir.
Is it possible to configure a shortcut (thought about something like shift shift) to insert |> in the editor?
Microsoft has its own tool to create custom layouts.
Microsoft Keyboard Layout Creator 1.4 Download.
Here is a brief how-to gracefully stolen from MakeUseOf
Open the Microsoft Keyboard Layout Creator app.
Head to File > Load Existing Keyboard.
Pick the layout you want to customize. You should make sure you pick the layout that matches your current keyboard setup, for example, QWERTY (U.S.).
Go to File > Save Source File As so you have a backup before you start making changes.
Set your new keyboard’s parameters in Project > Properties. You can pick a language and give the keyboard a name and description.
Click on a key and follow the on-screen prompt to remap it to a character of your choosing.
Assigning control keys combinations to input letters is not possible, AFAIK. Just set it so Shift+Something or to any 3rd level key. BTW, I am pretty sure your current 3rd level already has a pipe, to test it press the right Alt (also called AltGr) and press all the alphanumeric keys.
{
"key": "shift shift",
"command": "type",
"args": {
"text": "|>"
},
"when": "editorTextFocus"
}
Looks like using two modifier keys in rapid sequence will work soon. Commit merged: see Feature: Shift Shift, Ctrl Ctrl, Alt Alt Keybinds (Double press modifer keybind support)
Will be in v1.54 - works in the Insiders Build now.
You can define a keyboard shortcut
{
"key": "shift+alt+p",
"command": "type",
"args": { "text": "|>" },
"when": "editorTextFocus"
}
You can choose any key combo you like, see the docs

VS code on win 10 - create keybinding for capslock+i/j/k/l to act as arrow buttons

I have a 60% mechanical keyboard where the capslock works as an fn button. By pressing FN + i/j/k/l, it works as the arrow buttons.
I would like to replicate this behavior on the laptop's keyboard (for the sake when I don't have the keyboard with me), but by what I saw so far it won't work (sharpkeys and keytweak), so I had hoped to do it at least on the VS code, which is the place where I miss this at most.
I've tried to add it as keybinding on the keybindings.json, but I must be doing something wrong. Does anybody knows if it's possible and how to do it?
Here are some of the things I tried, and the one that "worked":
{
// "key": "shift+capslock shift+i", // works once at a time
// "key": "0x14 + i", // DOESN'T WORK
// "key": "VK_CAPITAL+i", // DOESN'T WORK
// "key": "VirtualKeyCode.VK_CAPITAL+i", // DOESN'T WORK
// "key": "oem_14 i", // DOESN'T WORK
// "key": "[CapsLock]+i", // DOESN'T WORK
// "key": "capsLock+i", // DOESN'T WORK
"key": "capsLock i", // Works one key at a time
"command": "cursorLeft",
"when": "textInputFocus"
},
As you clarified in the comments, an acceptable solution is that you press capslock (and then must release it), then press i to move the cursor one character at a time. I made the command cursorLeft but you can make it whatever you want. It works whether caps are being locked or unlocked at the time.
The gif isn't the best at showing all the keystrokes, but (1) press capslock, (2) release the button, and (3) press i. Repeat.

Visual Studio Code: How to define key bindings for page-home and page-end

Whilst coding I frequently find myself needing to jump either to the top or bottom of a file, but I can't find a quick way to do this with a single key stroke. I tried to define a short cut in the key bindings, but I can't find a function like "page-home" and "page-end". I was going to use the alt key with the home button to jump to the top of a page and alt+end for the bottom.
ie I was expecting to be able to define say:
{ "key": "alt+home", "command": "[what is page home command]", "when":
"terminalFocus"}
So, are there such functions page-home/page-end (I may have this wrong, perhaps its defined as something else).
I've spotted a binding for "cmd+home" bound to "workbench.action.terminal.scrollToTop" which sounds like the right function (and a similar one for "cmd+end"), but they don't work.
UPDATE: I've tried to apply changes to the keybindings via the key bindings page, by defining the keystrokes I mentioned before, and it still does not work. Unless I'm doing something wrong, I . think there is a bug that needs to be reported, unless somebody can say otherwise.
Thanks.
The answer is in this GitHub post. The commands you're looking for are cursorTop and cursorBottom.
Open up the command palette (CTRL + SHIFT + P on Windows) and select Preferences: Open Keyboard Shortcuts File
Add in the following settings in keybindings.json:
{
"key": "ctrl+home",
"command": "cursorTop",
"when": "editorTextFocus"
},
{
"key": "ctrl+end",
"command": "cursorBottom",
"when": "editorTextFocus"
}
replacing the key with whatever shortcut you prefer.

How to assign number keys to sublime text keybinding

I want to create a macro in sublime text using the number key on my keyboard. Is this possible?
My attempts have given me these results:
This works for the number 1 key on the keypad but not on the number 1 key on the keyboad
{"keys": ["alt+keypad1"], "command": "run_macro_file", "args": {"file": "Packages/User/action_self.sublime-macro"}}
This works for the f1 key on the keypad.
{"keys": ["alt+f1"], "command": "run_macro_file", "args": {"file": "Packages/User/action_self.sublime-macro"}}
This does not work!
{"keys": ["alt+1"], "command": "run_macro_file", "args": {"file": "Packages/User/action_self.sublime-macro"}}
It seems like the last mentioned should work. Is there a way to use the numbers of the keyboard to run macros?
Any help will be greatly appreciated!
That should work just fine. For example, under Windows/Linux, that key is bound by default to switch to the first tab in the current tab group:
{ "keys": ["alt+1"], "command": "select_by_index", "args": { "index": 0 } },
Possible problems with this include your operating system/window manager seeing the key and handling it before it gets to sublime or having a keyboard layout that makes that key not map to what you think it does.
To check both, open the Sublime console (View > Show Console from the menu or press Ctrl+`) and enter the command:
sublime.log_input (True)
This will make sublime output to the console whenever you press a key. Press Alt+1 and see what it displays in the console.
If nothing displays, something global is eating the key before Sublime gets to see it, which might be a shortcut in your OS of some sort.
Otherwise, it will display what key it thinks you pressed. If it shows you alt+1, then it's seeing the key and your key binding is just not taking effect for some other reason (wrong filename, the command does not do what you think it does, etc) which is a different issue.
If it shows you a key but not what you expect it to be, that's a result of your keyboard layout. In this case you can either switch to a different keyboard layout or just bind with the key as Sublime is reporting it.
Once you're done, you should run sublime.log_input (False) in the console to turn off input logging (or restart Sublime).

Trigger advanced hover information with keyboard

In vscode when I mouse hover on let's say, a method call or property it will display some information. I can trigger same thing with keyboard shortcut CMD+H (on mac).
Now with the mouse when I hover while holding the CMD key it will display more information. How to trigger this (CMD+mouse hover) equivalent with keyboard ?
(I'm aware of ALT+F12, but it's not exactly the same trigger.)
Per official docs, the binding for 'Show Hover' is:
⌘K ⌘I
Remember that ⌘K is a 'chord', so do that first (Code will show "⌘K was pressed. Waiting for second key of chord..."), and then ⌘I.
Hope this helps. It's not the most elegant of bindings, but nothing to stop you changing it!
Note:-
For VSCodeVim users, this is: gh.
For Windows users, this is: Ctrl + K Ctrl + I
This answer elaborates on Jack's helpful answer by pointing out the command palette command and how to override its shortcut.
Open the command palette and type "show hover" to find the command.
The default shortcut does not work for me, so I added an override of Ctrl + Space + H.
To add your own override, open the command palette and type "keyboard shortcuts". That opens the shortcut editor. This is how mine looks.
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+space ctrl+h",
"command": "editor.action.showHover",
"when": "editorTextFocus"
}
]
There's a pull request to add this functionality, but it hasn't landed yet:
https://github.com/Microsoft/vscode/pull/59260
I think you are looking for keyboard shortcut for 'Definition Preview'.
command name: Show Definition Preview Hover
command:
editor.action.showDefinitionPreviewHover
To set a keyboard shortcut:
Open keyboard shortcuts
Search for Show Definition Preview Hover
Set your preferred shortcut
Add editorTextFocus to when expression
Or you can append this to your keybindings.json:
{
"key": "ctrl+alt+;",
"command": "editor.action.showDefinitionPreviewHover",
"when": "editorTextFocus"
}
Here ctrl+alt+; is shortcut key I have selected. You add your own.
Usefull reference:
https://code.visualstudio.com/updates/v1_40#_definition-preview-hover-from-the-keyboard
If you're using VSCodeVim, you can add this to your settings.json
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["g", "H"],
"commands": [
{
"command": "editor.action.showDefinitionPreviewHover"
}
]
}
]
By default if you enter gh it will open in hover state.
I have it configured so that if I press gH it shows me the advanced info.