gpt4 book ai didi

Is there a faster alternative to using the arrow keys?(有没有比使用箭头键更快的选择?)

转载 作者:bug小助手 更新时间:2023-10-25 10:36:28 30 4
gpt4 key购买 nike



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?

我经常用R编码,我刚刚意识到把手向下移动到箭头键上,然后再回到键盘上的字母对我来说是多么痛苦。在RStudio中,我必须定期这样做,因为Studio会自动完成某些Synax(如括号和引号),然后我必须按箭头键才能移出括号(或引号),这就消除了让R为我完成语法的任何可能优势。这对我来说格外昂贵,因为我是左撇子。有靠近字母键的箭头键的快捷方式吗?


更多回答

Use vim instead of rstudio :)

使用VIM而不是RStudio:)

Or there is actually a better solution. Type quotation mark or closing parenthesis in the place where it's got autocompleted - it will replace autocompleted entity. That way you don't have to use arrow keys.

或者,实际上有一个更好的解决方案。在自动完成的位置键入引号或右括号-它将替换自动完成的实体。这样你就不用用箭头键了。

Or turn on Vim keybindings in RStudio :-)

或在RStudio中启用Vim键绑定:-)

优秀答案推荐

Intro


To do this, you have two approaches in front:

要做到这一点,前面有两种方法:



  1. use your own code

  2. use 3rd party softwares


In this 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

在这个答案中,我介绍了最有效和最简单的方法,所以对于一些操作系统来说,编写自己的代码很容易和高效,而在另一些操作系统中,编写代码并不是真正有效,需要一项艰苦的工作,既没有成就,又浪费时间


Windows users - approach 1: using Microsoft PowerToys



  1. install powertoys from here

  2. open it and from sidebar menu go to "Keyboard Manager"

  3. under "shortcuts" section click on "Remap a shortcut"

  4. for "Physical Shortcut" sections you should add "Alt(Left)" and "L" and for "Mapped To" section you should type "Right"

  5. do step 4 again respectively for other key remaps you want

  6. click on "okay"
    that's it, you ready to go


Windows users - approach 2: using autohoykey


In this method you will use:

在此方法中,您将使用:



  • alt+I instead of

  • alt+K instead of

  • alt+J instead of

  • alt+L instead of


In order to use this feature, these are the steps in your way:

为了使用此功能,以下是阻碍您使用该功能的步骤:



  1. Download and install autohotkey

  2. Right-click in your desktop area then go to new and make a new "notepad" file

  3. Open empty notepad file and copy/paste codes below into that

  4. Rename your notepad file eveything you want but with *.ahk format

  5. Click your file to run your script


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}

Important Notes


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?

如何找到启动文件夹?



  1. win+R

  2. type: shell:startup

  3. copy your script into that Folder


MacOS users


In this method you will use

在这种方法中,您将使用



  • option+I instead of

  • option+K instead of

  • option+J instead of

  • option+L instead of


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

使用锤勺:是一个用于许多目的的强大工具(不仅仅是指定一个键绑定,例如,您可以将其用于Windows Sanping或...)我认为这是任何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

因为Hammerspoon的文档非常非常简单,所以我只在这里放了代码,您可以从Hammerspoon的入门开始安装和配置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)

Important Notes


If you think hammerspoon is slow or not working as genius as you want another option is Karabiner

如果你认为锤子很慢或者没有你想要的那么聪明,另一个选择是Karabiner


Debian-based Linux users (not Ubuntu; see important notes):


In this method you will use:

在此方法中,您将使用:



  • CapsLock+I instead of

  • CapsLock+K instead of

  • CapsLock+J instead of

  • CapsLock+L instead of


and



  • alt_gr instead of CapsLock


How? Well:

多么?好的:



  1. 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


  2. 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


  3. 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


  4. change keyCode 31 (i) value, so it should be like this after modifying:


    keycode  31 = i I Up NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol


  5. change keyCode 44 (j) value, so it should be like this after modifying:


    keycode  44 = j J Left NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol


  6. change keyCode 45 (k) value, so it should be like this after modifying:


    keycode  45 = k K Down NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol


  7. change keyCode 46 (l) value, so it should be like this after modifying:


    keycode  46 = l L Right NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol



Important Notes



  1. 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



  2. You can't use this solution easily if you got multi langs/inputs on your keyboard, but you can use it like below:



    • CapsLock+shift+i instead of

    • CapsLock+shift+k instead of

    • CapsLock+shift+j instead of

    • CapsLock+shift+l instead of




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:

例如,如果您还想使用波斯语输入,可以执行上面的步骤1、2、3,然后更改其他步骤,如下所示:


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

注意不要在终端中测试上述键盘快捷键



  1. 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.



  2. In most cases, alt_Gr is the right alt Key on your keyboard




further reading about xmodmap on ArchWiki

在ArchWiki上进一步阅读有关xmodmap的内容


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

如果任何人在BSD操作系统(或基于BSD)中知道这个答案,我将非常感谢他/她将其添加到我的答案中



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:

两周前,微软在微软商店推出了“Power Toys”。您可以使用键盘管理器创建回答中提到的箭头键的快捷键。我使用VIM快捷键作为箭头键,如下所示:


added shortcuts for arrow keys
1: https://i.stack.imgur.com/F9syJ.png

添加了箭头键1的快捷键:



New Script working with Autohotkey v2:

使用自动热键v2的新脚本:


; Since the comments mention the effect and description of each hotkey, I'm keeping only the hotkey definitions for brevity.

; SetWorkingDir has changed in v2. You now directly assign to A_WorkingDir.
A_WorkingDir := A_ScriptDir

; ALT Keypress Implied for all below
!k::Send("{UP}")
!j::Send("{DOWN}")
!h::Send("{LEFT}")
!l::Send("{RIGHT}")

; CTRL + ALT Keypress Implied for all below
!^h::Send("^{LEFT}")
!^l::Send("^{RIGHT}")

; SHIFT + ALT Keypress Implied for all below
!+k::Send("+{UP}")
!+j::Send("+{DOWN}")
!+h::Send("+{LEFT}")
!+l::Send("+{RIGHT}")


; SHIFT + CTRL + ALT Keypress Implied for all below
!+^h::Send("+^{LEFT}")
!+^l::Send("+^{RIGHT}")
!+^k::Send("+!{UP}")
!+^j::Send("+!{DOWN}")

; CTRL + SHIFT Keypress Implied for all below
+^k::Send("+^{UP}")
+^j::Send("+^{DOWN}")


I have the same pain, I've tried to use hjkl as arrow keys, and some layout like fun plus wsad. But now I have gotten the best solution since I got a Filco Minila-R. It divided space key into three keys, two function on two sides of sapce key. Like when I type right arrow, I hold the left fn key (at the left side of space) with my left hand thumb while touch F key, F key always used for locating for left hand.
e-d-f-s plus left function keys achived up-down-right-left, right function plus jm-k,-l. achived ins del-home end-pu pd.
If I use capslock + hjkl, I have to use two hands, Minila-R layout allows me using one sigle hand to touch this keys, besides, the two functions which devided from space key just at the most fine place for thumb to touch.

我也有同样的痛苦,我试着用hjkl作为箭头键,还有一些布局,比如FUN加WSAD。但现在我得到了最好的解决方案,因为我得到了Filco Minila-R。它将空格键分为三个键,空格键两侧各有两个功能。就像我输入右箭头时,我用左手拇指按住左Fn键(在空间的左侧),同时触摸F键,F键总是用来定位左手。E-d-f-S加左功能键实现了上、下、右、右功能加JM-k、-L。取得了成功-家庭结束-PU PD。如果我使用Capslock+Hjkl,我必须用两只手,Minila-R布局允许我用一只手触摸这些键,此外,除了在拇指最精细的地方使用空格键之外的两个功能。


更多回答

Hammerspoon is quite slow, I would not consider it as a solution

哈默斯彭速度很慢,我不认为这是一个解决方案

@nick318 well it's actually working perfect in my macbook-pro-2019-mvvk2, maybe it's about your system or your inappropriate version of hammerspoon. after all i think it's worth to think that maybe it's your problem instead of a 7.2k stared project on github

@ick318它实际上在我的MacBook-PRO-2019-mvvk2上运行得很好,也许是因为你的系统或你不合适的锤勺版本。毕竟,我认为值得考虑的是,也许这是你的问题,而不是GitHub上一个7.2K的启动项目

@nick318 use vim editor and configure it to using jkli instead of arrow keys just for programming you can use vim editor which is actually more professional than every other code-editor but your problem is still a pit if you want using jkli instead of arrow keys in other places like IDEs or in your whole OS.

@ick318使用vim编辑器并将其配置为使用jkli而不是仅用于编程的箭头键。您可以使用vim编辑器,它实际上比其他任何代码编辑器都更专业,但如果您想在其他地方使用jkli而不是箭头键,例如在IDE中或在您的整个操作系统中,您的问题仍然是一个难题。

@nick318 anyway i will find a native way for this purpose in macos whenever i have time and will update this post again

@nick318无论如何,我会找到一个原生的方式,为这一目的在macos每当我有时间,并会更新这篇文章再次

@nick318 ok, you can consider karabiner as an alternative now, link is in description

@ick318好的,你现在可以考虑Karabiner作为替代,链接在描述中

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

正如它目前所写的,你的答案并不清楚。请编辑以添加更多详细信息,以帮助其他人了解这是如何解决提出的问题的。你可以在帮助中心找到更多关于如何写出好答案的信息。

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com