An AutoHotkey script to move the cursor two words - autohotkey

I'm attempting to write an AutoHotkey script that moves the cursor to the beginning of the second next word, in a similar way that Window's ctrl + arrows and fn + arrows shortcuts works.
I use very often this pair of shortcuts, but I frequently find that the first one moves the cursor too slowly and the second one too fast. So I would like to get a script that moves the caret, as described, two words instead of one (for example, when pressing ctrl + alt + arrows).
I've never scripted for automated actions on the keyboard before, so this is all new territory for me. I assume anyone with some experience could implement the above in a minute or two.

I have realized that it is much easier than writing an AutoHotkey script, it can be done by recording a macro in Microsoft Word.

Related

In VSode, is there a way to add a toast notification that a shortcut has been used?

I'm still new to VS Code and learning the litany of shortcuts and features.
Some shortcuts have multiple steps and it isn't immediately apparently if it's been fired.
For example, remove trailing whitespaces is CTRL + K, CTRL + X.
The only way to tell if it worked is to move my cursor to a line that has whitespace and see if it's gone.
Is there a way to add a small notification that announces when a shortcut is used?
I know I could alternatively use the Command Palette but I'd like to be more efficient as use KB Shortcuts.
Thank you

How to jump out of quote or jump out of code block with vim in vscode?

I'm learning Vim for few days and I have a question when coding with vim.
Let say I'm creating an object like this
const person = {
name: "Tu<my pointer after u character>"
}
What is the best way to move my pointer from after u character to after the double quote so I can keep writing my object
Another case is if I finish create object like this
const person = {
name: "Tu<my pointer after u character>"
}
How do I get my pointer to the line after the close curly bracket to keep writing code.
Some people say that I can escape the insert mode and using shift + A to go end of line but it takes 4 buttons to do that?
Thanks for answering my question.
Indeed the way to do it is to escape insert mode and use A to
[A]ppend stuff to the end of the line. To jump to the } in your code, there
are many many options, and which to use depends on the situation and user
preference, but I tend to use something like 3j to move 3 lines down (or
however many I need to move). And by putting the following in my vimrc:
set number
set relativenumber
I always know what number of lines I want to move.
Vim seems a bit weird for about 2 weeks (for me at least, when I started coding
in Vim) but after that it becomes automatic that if I finish inserting text for
any reason, I instinctively hit Esc. Many (most?) vim users remap
the some other key like CapsLock to act like Esc, since the Esc key on
modern keyboards is in an awkward position (unlike in the early days).
Once the 'modal' nature of vim becomes natural for you, things will fall into
place.
Oh, and it really helps if you learn to touch type 100% (i.e. never need to
look at the keyboard - even for numbers, punctuation, 'weird symbols' etc.)
Good luck!
In the first case, press <Right> or <End>, just like in any editor.
In the second case, press <Down> to move the caret after the }, then press <CR> (to open a new line) or <Down> (to move the caret to the line after the }), just like in any editor.
Going back to normal mode just for that is silly.
Note that you wouldn't have to deal with this without whatever you installed that closes quotes automatically.

VSCode move selection of multiple lines up and down

I am trying to get used to VSCode because of dendron and I am friend of learning defaults because I work on too many installs to maintain custom settings.
Is there any equivalent in VSCode to sublime text multiline movement?
I have attached a GIF to show what I mean because I can't seem to find the right google keywords or everyone else means something else than me with saying move multiple cursor lines vertically.
In ST I can move them after selecting them with a cursor via SHIFT + CTRL + Up/Down
GIF of st3 multi line movement
EDIT: Found it. Sublime Text 3 can move blocks by cursor, vscode can't. It only moves by selection. Which ironically work with a single line cursor though.
Select all lines which you want to move up/down then Alt + (arrow key up/ arrow key down ) to move your piece of code up or down.

autohotkey does not exist in current keyboard layout - solution examples

I have written a python script for my co-workers, and then created an autohotkey script to run it every time someone presses Ctrl+LShift+Y. Looks something like this:
^+y::Run helper.py
The python script is fine, but the ahk script doesn't work on all the computers. Sometimes it works fine, and sometimes you get this error:
^+y does not exist in current keyboard layout
Now, searching the web this seems to be a problem with multi-language keyboards (we're using both Hebrew and English), because different languages means a different layouts (I guess?). I also found someone explaining that to solve this you need to use scan codes instead of the usual ^ and + and so on (I'd link to it but I cannot seem to find it now).
This all vaguely makes sense to me on a theoretical level, but when I want to realize it with actual code, I don't really know what to do. To me it seems as if this topic is hardly discussed (with the few exceptions being lacking in examples or hard to understand), so I'd love an answer that would include the following:
some simple way of determining the scan code for a key. This should preferably be a pythonic solution (and just out of curiosity, I'd love to know how to do this with linux as well). This is probably the easier part (but I think is an inherent part of a complete answer).
This is the important part: examples of how you implement that scan code in an autohotkey script, including edge-cases (if there are any).
Question 1
As you want to use the key with autohotkey, it makes sense to use autohotkey detect the key in the first place. Obviously this method works only on windows where autohotkey is running.
Write a Autohotkey script with this line and run it.
#InstallKeybdHook
Press the key you want to examine.
Open the script menu by right clicking the icon of the script in the right lower corner of your screen.
Select OPEN, then from the Menu "View / Key history and script info"
There is a line for each keypress.
First column is the VK (Virtual key) code, next is the scancode.
For example for CAPSLOCK the VK is 14 and the Scancode 03a
Question 2:
#InstallKeybdHook
VK14::
msgbox, you pressed capslock!
return
OR
#InstallKeybdHook
SC03a::
msgbox, you pressed capslock!
return
both work.
Note that you can combine two keys into a hotkey by combining them with & (but not 3)
#InstallKeybdHook
RShift & SC03a::
msgbox, you pressed Rshift capslock!
return
You can modify a Scancode with + and ^
#InstallKeybdHook
^+SC02C::
msgbox, you pressed Ctrl Shift and Y(maybe)!
return
Further info about this is on the page "List of Keys, Mouse Buttons, and Joystick Controls" of the autohotkey help file that comes with the default installation.

Eclipse: Text Editing Without Mouse

I have bandage due to 5th metacarpal damage. Typing is no issue at all, I do hours of it and it's fine. Using a mouse... impossible. This is not about being a productivity ninja not losing the time it takes to reach for the trackpad or the mouse... it's actual being able to do some stuff or not at all for the moment. Anyway, here's the question, put simply and clearly:
In an Eclipse editor, can I move around using the keyboard only?
Examples of actual things I would like to be able to do without using a mouse:
Move the cursor to the end of the line
Move the cursor to the beginning of the line
Move the cursor one line down
Move the cursor one line up
Move the cursor one column left
Move the cursor one column right
Move the cursor one word left
Move the cursor one work right
Move the cursor to the end of the word
Move the cursor to the beginning of the word
Delete the character to the left of the cursor
Delete the character to the right of the cursor
etc.
I realise some of this is possible already using a mixture of END, HOME, CTRL/ALT + ARROW_KEY, etc. But it's not as comprehensive as, say, E-Macs or Vim.
As simple as that.
In Vim, I use j,k,h,l... in Xcode I use Emacs bindings (CTRL-N, CTRL-P, CTRL-H)... how can I use Eclipse in a similar way? I have heard of a "vim" plug-in but I really just need the cursor movement, that's it. Nothing else.
Should I just create custom shortcuts for each movement?!
Going to the end of the line: End key
Going to the start of the line: Home key
Going one line down: down arrow key
Move the cursor one line up: up arrow key
Move the cursor one column left: don't know what you mean by column
Move the cursor one column right: idem
Move the cursor one word left: ctrl - left arrow key
Move the cursor one word right: ctrl - right arrow key
Move the cursor to the end of the word: no idea
Move the cursor to the beginning of the word: ctrl - left arrow key
Delete the character to the left of the cursor: backspace
Delete the character to the right of the cursor: delete
This is on Windows. All the shortcuts are available in Window (Alt W) - Preferences (P) - General - Keys (type "Keys" in the filter text box). Most of the shortcuts above are standard shortcuts, which are used in every windows editor.
I found it :(
Preferences > General > Keys > Emacs
You can do almost everything with your keyboard:
Take a look here for a detailed list of shortcuts:
http://www.shortcutworld.com/en/win/Eclipse.html