I regularly code in R, and I just realized how much of a pain it is for me to move my hand down to the arrow keys and then back to they letters on the keyboard. In Rstudio, I have to do this regularly because the studio completes certain synax automatically, (like parentheses and quotation marks) and then I have to press the arrow key to move out of the parentheses (or quotation marks), this then removed any possible advantage from having R complete the syntax for me. This is extra costly for me because I'm left handed. Is there a shortcut for the arrow keys that's closer to the letter keys?
If you hold the "Ctrl" key down, and then "hold down" the Right arrow key or the Left Arrow key, the cursor will jump quickly from word to word. This is even faster than holding an arrow key down without the Ctrl key.
Fortunately, on most keyboards, you can toggle between the standard-setting and the alternate key setting by pressing FN + W keys. If that doesn't work, here are a couple of other key combinations that are known to disable the alternate keys settings: FN + Windows key.
To do this, you have two approaches in front:
In these answer I introduce the most efficient and easy approach so for some OSs it's easy and efficient to write your own code while in others it's not really efficient and need a harsh work which have no achivement but wasting time
In this method you will use:
In order to use this feature, these are the steps in your way:
Now you can enjoy and never use arrow keys again...
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; AHK Command ; key = Effect (Description)
; ALT Keypress Implied for all below
!i::Send {UP} ; i UP (Cursor up line)
!k::Send {DOWN} ; k DOWN (Cursor down line)
!j::Send {LEFT} ; j LEFT (Cursor left one character)
!l::Send {RIGHT} ; l RIGHT (Cursor right one character)
!h::Send {HOME} ; h ALT + RIGHT (Cursor to beginning of line)
!;::Send {END} ; ; ALT + LEFT (Cursor to end of line)
!u::Send ^{HOME} ; h SHIFT + HOME (Cursor to beginning of document)
!o::Send ^{END} ; o SHIFT + END (Cursor to end of document)
; CTRL + ALT Keypress Implied for all below
!^j::Send ^{LEFT} ; j CTRL + LEFT (Cursor left per word)
!^l::Send ^{RIGHT} ; l CTRL + RIGHT (Cursor right per word)
; SHIFT + ALT Keypress Implied for all below
!+i::Send +{UP} ; i SHIFT + UP (Highlight per line)
!+k::Send +{DOWN} ; k SHIFT + DOWN (Highlight per line)
!+j::Send +{LEFT} ; j SHIFT + LEFT (Highlight per character)
!+l::Send +{RIGHT} ; l SHIFT + RIGHT (Highlight per character)
!+h::Send +{HOME} ; h SHIFT + ALT + LEFT (Highlight to beginning of line)
!+;::Send +{END} ; ; SHIFT + ALT + RIGHT (Hightlight to end of line)
!+u::Send ^+{HOME} ; u SHIFT + CTRL + HOME (Highlight to beggininng of document)
!+o::Send ^+{END} ; o SHIFT + CTRL + END (Hightlight to end of document)
; SHIFT + CTRL + ALT Keypress Implied for all below
!+^j::Send +^{LEFT} ; j SHIFT + CTRL + LEFT (Highlight per word)
!+^l::Send +^{RIGHT} ; l SHIFT + CTRL + RIGHT (Hightlight per word)
!+^i::Send +!{UP} ; i SHIFT + ALT + UP (Multiply cursor up)
!+^k::Send +!{DOWN} ; k SHIFT + ALT + DOWN (Multiply cursor down)
; CTRL + SHIFT Keypress Implied for all below
+^i::Send +^{UP}
+^k::Send +^{DOWN}
To use autohotkey script which you made, every time you turn on computer instead of clicking on your script every time, you can copy your script in startup folder.
How to find startup folder?
In this method you will use
Use hammerspoon: Is a tremendous tool for many purposes (not just assign a keybinding, for example you can use it for windows sanping or ...) and I think that is one of the MUST-HAVE tools in any macos
Since the documentation of hammerspoon is very very straightforward, I just put the code here and you can install and config hammerspoon from it's Getting Started with Hammerspoon
hs.hotkey.bind({"alt"}, "I", function()
hs.eventtap.keyStroke({}, "up")
end)
hs.hotkey.bind({"alt"}, "K", function()
hs.eventtap.keyStroke({}, "down")
end)
hs.hotkey.bind({"alt"}, "J", function()
hs.eventtap.keyStroke({}, "left")
end)
hs.hotkey.bind({"alt"}, "L", function()
hs.eventtap.keyStroke({}, "right")
end)
If you think hammerspoon is slow or not working as genius as you want another option is Karabiner
In this method you will use:
and
How? Well:
open up Terminal, write your keyboard layout on in a file(I named it modmap), then open that file and edit it as you will follow next steps:
xmodmap -pke > modmap
gedit modmap
change keyCode 108 (alt_Gr/ISO_Level3_Shift) value, so it should be like this after modifying:
keycode 108 = Caps_Lock Caps_Lock Caps_Lock Caps_Lock Caps_Lock Caps_Lock
change keyCode 66 (CapsLock) value, so it should be like this after modifying:
keycode 66 = Mode_switch Mode_switch Mode_switch Mode_switch Mode_switch Mode_switch
change keyCode 31 (i) value, so it should be like this after modifying:
keycode 31 = i I Up NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol
change keyCode 44 (j) value, so it should be like this after modifying:
keycode 44 = j J Left NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol
change keyCode 45 (k) value, so it should be like this after modifying:
keycode 45 = k K Down NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol
change keyCode 46 (l) value, so it should be like this after modifying:
keycode 46 = l L Right NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol
xmodmap is no longer used/supported on Ubuntu (because it wasn't handy for many users, I think they stop using xmodmap from 2013) but since this is a professional question for very fast coding and working with computer and also coding, I see many professionals using Debian or their own debian-based Linux (not Ubuntu) and they always prefer native solutions to plugins or... Anyway if you are using Ubuntu you can use xkb or gnome tweak tools where you maybe can adjust your keyboard mapping in a GUI
You can't use this solution easily if you got multi langs/inputs on your keyboard, but you can use it like below:
for example, if you also want to have persian_language_input you can do step 1,2,3 above then change other steps like below:
keycode 31 = i I Arabic_heh Up 5 6 7 8
keycode 44 = j J Arabic_teh Left 5 6 7 8
keycode 45 = k K Arabic_noon Down 5 6 7 8
keycode 46 = l L Arabic_meem Right 5 6 7 8
be careful that you shouldn't test above keyboard shortcuts in Terminal
Since we're using xmodmap
tool (because it's native unlike xkb), You can only change the AltGr keysyms for keycodes that are already using AltGr. So we change it with CapsLock to overcome this problem since CapsLock is more comfort for fingers to find it is a very acceptable solution.
In most cases, alt_Gr is the right alt Key on your keyboard
further reading about xmodmap on ArchWiki
if anyone has knowledge about this answer in BSD OS (or BSD-BASED) I'll appreciate that if he/she add it to my answer
Two weeks back Microsoft launched "Power Toys" in the Microsoft Store. You can use the keyboard manager to create a shortcut for arrow keys as mentioned in answer. I use the vim shortcut for arrow keys as shown below:
[added shortcuts for arrow keys][1] [1]: https://i.stack.imgur.com/F9syJ.png
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With