热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何在VIM中重新映射键盘键以避免RSI?-HowtoremapkeyboardkeystoavoidRSIinVIM

Ihopethisdoesnotcomeacrossasanattempttosparkconversationpurelyforthesakeofdoingso

I hope this does not come across as an attempt to spark conversation purely for the sake of doing so.

我希望这不会成为一种纯粹为了这样做而引发对话的尝试。

I use vim a great deal (5-10 hours a day) and I noticed my left wrist is the first to start aching. The standard keyboard layout (see image below) is almost guaranteed to give you arthritis.

我经常使用vim(每天5-10小时),我注意到我的左腕是第一个开始疼痛的。标准键盘布局(见下图)几乎可以保证给你带来关节炎。

Standard Keyboard

Currently, I have remapped

目前,我有重新映射

  • Ctrl to Shift
  • Ctrl键来改变
  • Shift to Caps Lock
  • 转向大写锁定
  • Caps Lock to Ctrl
  • 大写锁定到任务

This helps with common commands such as Ctrlf or Shift2 (@), but I still have to twist my wrist to get at those combinations. Is there anyway to remap the keys so as to avoid this twisting on the left wrist (maybe use the Tab key)? I just find it odd that for a text editor designed specifically for programmers, it would make heavy use of these out of the way keys. I have considered remapping to the old keyboard layout (see below image), but I don't want to learn that if it is going to have the same fundamental problems as my current remapping.

这有助于使用常见的命令,比如ctrl + f或Shift2(@),但我仍然需要拧手腕才能得到这些组合。为了避免左手腕上的扭曲(可能使用Tab键),是否需要重新映射键?我只是觉得,对于专门为程序员设计的文本编辑器,它会大量使用这些方法。我已经考虑过对旧键盘布局进行重新映射(见下图),但我不想知道,如果它和我现在的重新映射有相同的基本问题。

old keyboard layout

8 个解决方案

#1


14  

Note: I am not a doctor, just another typist that suffered from wrist pain.


In my experience, just mapping Caps to Ctrl (or swapping the two if you must have a Caps) and using Ctrl+[ instead of Esc make a big difference. Ctrl+[ does not require an additional mapping in vim as it is equivalent to Esc. If you can teach yourself this small change you reduce your movement by a great deal when you consider how often you use Esc in vim.

根据我的经验,只要将大写字母设置为Ctrl(如果你必须有一个大写字母,就把它们交换一下),并使用Ctrl+(而不是Esc)会产生很大的不同。在vim中不需要额外的映射,因为它等同于Esc。如果你可以自学这个小的改变,当你考虑在vim中使用Esc的频率时,你会大大减少你的动作。

The Caps to Ctrl mapping can't be done inside vim and will have to be made system-wide, however, having Ctrl in the more convenient location will also help in other applications that use Ctrl combinations. There are different methods of remapping keys depending on which OS you're using. A few common options are:

在vim中不能完成对Ctrl映射的限制,而且必须在系统范围内完成,但是,在更方便的位置上使用Ctrl,也可以帮助其他使用Ctrl组合的应用程序。根据您使用的操作系统,有不同的重新映射键的方法。一些常见的选项是:

  • xmodmap (GNU/Linux)
  • xmodmap(GNU / Linux)
  • KeyRemap4Macbook (OSX)
  • KeyRemap4Macbook(OSX)
  • KeyTweak (Windows)
  • KeyTweak(Windows)

While this will probably improve your situation you really should consider seeing a doctor and/or purchasing a more ergonomically designed keyboard if your pain persists. I own an older version of the Kinesis Advantage that I picked up used on Ebay for about $100 (USD) and I couldn't be happier. The keys can be programmed directly on the keyboard so no software is needed to swap keys or create your own keyboard macros for frequently used key strokes.

虽然这可能会改善你的情况,但如果你的疼痛持续,你真的应该考虑去看医生或者买一个更符合人体工程学的键盘。我拥有一个旧版的Kinesis优势,我在Ebay上花了大约100美元(美元)买了它,我很高兴。键可以直接在键盘上编程,所以不需要软件来交换键或创建你自己的键盘宏来频繁地使用按键。


Edit: I see in your post you also mention combinations like Ctrl+f and Shift+2 requiring you to twist your wrist to press. It sounds to me like you're only using the Ctrl and Shift keys on the left side of your keyboard. You should really be using both sets of these keys, using whichever one is on the opposite hand of the key you're modifying. That would negate this wrist movement.

编辑:我在你的文章中看到你还提到了像Ctrl+f和Shift+2这样的组合,这需要你扭手腕来按。在我看来,你只是在键盘的左边使用Ctrl和Shift键。实际上,您应该使用这两组键,使用的是您正在修改的键的另一端。这将会否定这个手腕动作。

#2


6  

Use caps as ctrl systemwide. (How often do you cut/copy/paste?)

使用caps作为ctrl systemwide。(你多久剪一次/复制/粘贴?)

This also makes ctrl[ work in vim.

这也使ctrl[在vim中工作。

Alongside I use the vim 'arpeggio' plugin.

同时我还使用vim的arpeggio插件。

Arpeggio lets you define vim bindings that are activated when two keys are simultanously pressed.
jk pressed serves me as ESC.

Arpeggio允许您定义在两个密钥被模拟地按下时激活的vim绑定。jk给我的是ESC。

Also the 'surround.vim' plugin might be interesting for you.

还“包围。vim的插件可能对你来说很有趣。

Eliminated all my wrist pains.

消除了我所有的手腕疼痛。

post scriptum:
Use 'vundle'!
Its the best vim plugin manager by far, and you will wonder how you could ever do without, especially if you use a customized vim on several machines. Don't be scared if you have trouble setting it up initially, take your time.

后记:使用“vundle”!它是迄今为止最好的vim插件管理器,您会想知道如何才能不使用它,特别是如果您在几台机器上使用定制的vim。如果你一开始就有困难,不要害怕,慢慢来。

#3


4  

I switched to a Kinesis Advantage keyboard, and remapped Caps Lock to Esc. This effectively removed any wrist pain I felt as a vim user.Once again not a doctor, but looking at how my hands move, I don't see my wrist twisting even when I hit Shift.

我切换到一个Kinesis优势键盘,并将大写锁定到Esc。这有效地消除了我作为一个vim用户的任何手腕疼痛。再一次不是医生,而是看我的手如何移动,我没有看到我的手腕扭曲,即使我上了班。

You could probably do some great remappings to the thumb keys to further minimise tension, but to be honest I've never felt the need.

你可能会对拇指键做一些巨大的调整,以进一步减少紧张感,但说实话,我从来没有感觉到需要。

Not a $0 solution, I'm afraid, but it was very effective for me.

我担心这不是一个0美元的解决方案,但对我来说很有效。

#4


3  

I mapped both Escape (single tap) and Ctrl (hold) to CapsLock:

我将Escape (single tap)和Ctrl (hold)映射到CapsLock:

xmodmap -e "remove Lock = Caps_Lock"
xmodmap -e "remove COntrol= Control_L"
xmodmap -e "keysym Control_L = Caps_Lock"
xmodmap -e "keysym Caps_Lock = Control_L"
xmodmap -e "add COntrol= Control_L"
xcape -t 1000 -e "Control_L=Escape" # Fire nothing if 1000ms hold time out

Probably I'm messing things up here, but xmodmap isn't the best option to modify mappings anyway, so I will change that to pure xkb config.

可能我在这里搞混了,但是xmodmap并不是修改映射的最佳选项,所以我将把它改为纯xkb配置。

I have also swapped : with ; and ` with ~, since I use : and ~ more often:

我也交换了;和“with ~,因为我使用:和~更经常:

xmodmap -e "keycode 47 = colon semicolon"
xmodmap -e "keycode 49 = asciitilde grave"

I also use Compose Key to be ablo to type ūmlauts et c.

我也使用组合键abloūmlauts et型c。

In vim, most useful change I have ever made is mapping of space to leader. All kinds of leader-key combinations will make you life easier.

在vim中,我所做的最有用的改变是将空间映射到leader。各种各样的领导组合会让你的生活更轻松。

I couldn't get use to H and L for _ and $, since it doesn't seem to work with surround.vim and some other tricks people advise.

我不能用H和L来表示_和$,因为它似乎不适合环绕。vim和其他一些人建议的技巧。

Just don't use arrows!

只是不使用箭!

#5


2  

I'd make this part a comment to Randy's answer on Esc if I could, but it demands a little more space. There's one important use case where you can't just remap Windows keys: Windows 7 without admin rights. It's common enough in an enterprise environment; at the very least, it describes me and that keyboard in the pic. keymapper's repo has decent info on this issue:

如果我可以的话,我会把这部分作为兰迪对Esc的回答,但它需要更多的空间。有一个重要的用例,您不能仅仅重新映射Windows密钥:没有管理员权限的Windows 7。在企业环境中是很常见的;至少,它描述了我和图片中的键盘。keymapper的repo在这个问题上有很好的信息:

Important note for Windows 7 Users

Windows 7用户的重要提示。

Windows 7 does not support per-user key mappings. Until the next release of Key Mapper, you will have to manually switch to 'Boot' mappings from the Mappings menu, reboot to change the mappings, and you will need to have Administrative access to your computer to set key mappings that will work in Windows 7.

Windows 7不支持每个用户的键映射。直到下一个密钥映射器发布之前,您必须手动切换到映射菜单中的“引导”映射,重新启动来更改映射,您将需要对您的计算机进行管理访问,以设置将在Windows 7中工作的键映射。

The same is true for any Microsoft tools, KeyTweak, SharpKey, etc.

对于任何微软工具,关键字,尖刀,等等,都是如此。

So you'll have to use something like AutoHotkey. I personally prefer mapping Caps Lock directly to Esc for Vim, and I've had issues just mapping it to Ctrl:

所以你必须使用自动热键。我个人更喜欢直接将大写锁定到Esc的Vim,并且我有一些问题只是将它映射到Ctrl:

#IfWinActive ahk_class Vim
*CapsLock::Esc
#IfWinActive

Another alternative I like is inoremap jj . Unless you plan to write about a hajj or something it works pretty well.

我喜欢的另一种选择是inoremap jj 。除非你打算写一篇关于朝觐的文章,或者写一些很不错的东西。


More to your point

In any case, have you considered doing the above for easy escaping and then remapping some of the hard-to-reach insert mode commands to Alt (hit it with your thumb) and then using mappings to your leader?

在任何情况下,您是否考虑过执行上述操作,以便轻松地转接,然后将一些难以到达的插入模式命令重新映射到Alt(用您的拇指点击),然后使用映射到您的领导?

let mapleader=","
nnoremap f 

#6


1  

I would suggest remapping

我建议重新映射

  • Caps lock to left Control
  • 大写锁定为左控制。
  • Left Control to Escape
  • 而离开控制
  • Escape to Caps lock
  • 逃到大写锁定

. If in linux first can be done by using setxkbmap -option '...,ctrl:nocaps' or changing XkbOptions in /etc/X11/xorg.conf. Second requires using of xmodmap. After some X server update I failed to get the third working, previously used xmodmap as well.

。如果在linux中,首先可以使用setxkbmap -option '…在/etc/ x11 /xorg. conf中,ctrl:nocaps'或更改XkbOptions。第二,需要使用xmodmap。在一些X服务器更新之后,我没有得到第三个工作,之前也使用了xmodmap。

Using dvorak layout (maybe even programming) that is optimized for touch typing and mappings like ,s->() might also help.

使用dvorak布局(甚至可能是编程)对触摸类型和映射进行了优化,例如,s->() <左侧> 也可能有帮助。

Note: I am not a doctor as well. I am touch typist, but unlike @Randy Morris I never suffered from the wrist pain, just moved keys to the most convenient locations.

注意:我也不是医生。我是touch打字员,但与@Randy Morris不同的是,我从来没有遭受过手腕疼痛,只是把钥匙移动到最方便的位置。

#7


1  

I always press the left ctrl key by curling up my pinky and pressing with the first knuckle. I find this requires less hand movement.

我总是按下ctrl键,把我的小指卷起来,然后用第一个关节。我发现这需要更少的手部运动。

Update

更新

I don't find Shift uncomfortable, so I can't help you with that. However Ctrl does bother me, and even with my knuckle technique I prefer to avoid it where possible. So for insert mode (and command-line mode) I use a leading ; instead of Ctrl. E.g.

我觉得换班不舒服,所以我不能帮你。但是,Ctrl确实会影响我,即使是我的指关节技巧,我还是尽量避免使用它。所以对于插入模式(和命令行模式),我使用一个引导;而不是控制。如。

:map! ;w 
:map! ;a 
:map! ;r 
:ino  ;t 
:ino  ;d 

You get the idea.

你懂的。

In normal mode I use v and V instead of Ctrl+F and Ctrl+B (I only use visual blockwise mode), though I imagine most people would prefer to map different keys, such as and - for paging (- isn't really needed). Instead of F you could search forwards with f, and then hit ,.

在正常模式下,我使用的是v和v,而不是Ctrl+F和Ctrl+B(我只使用visual blockwise模式),不过我想大多数人更喜欢映射不同的键,比如 和- for分页(-不需要)。而不是F你可以用F搜索,然后点击。

I've never really seen much point in Ctrl+D or Ctrl+U. However I do find z., z, and z- useful for scrolling the line with the cursor to the middle, top, and bottom of the window respectively. H, M and L are also useful for moving the cursor around the screen. But in general I prefer to just use / with 'incsearch' set for navigating about.

我从来没见过Ctrl+D或者Ctrl+U。但是我确实找到了z。,z , z-用于将光标移动到窗口的中间、顶部和底部。H, M和L对于在屏幕上移动光标也很有用。但总的来说,我更喜欢用“incsearch”来导航。

There's no right or wrong way to do this, these are just my personal preferences, but I hope it gives you one or two ideas. Try experimenting and see what works for you.

没有正确或错误的方法,这些只是我个人的喜好,但我希望它能给你一个或两个想法。试着尝试一下,看看有什么对你有用。

#8


1  

I've developed a vim module to do some simple remappings for exactly this issue:

我已经开发了一个vim模块,为这个问题做一些简单的修改:

https://github.com/vim-scripts/vim.ergonomic

https://github.com/vim-scripts/vim.ergonomic

The biggest things it does is make it easier to type bracket sets. It also makes it much easier to get into command mode (jj->ESC)

它所做的最大的事情是使它更容易类型的托架集。它也使进入命令模式变得更容易(jj->ESC)

It runs on the principle that you hardly ever used the J key while editing, but it is right there in the home row... so let's abuse it!

它遵循的原则是,在编辑时几乎不使用J键,但是它就在home row中。我们滥用它!

from the documentation:

从文档:

Remapping commonly used commands
  key combo     mapping         purpose
  ;             :               removes the need to hit Shift to use commands
  jj                       can exit edit mode quickly and easily
  Jj            j               can type 'j' when you need to
  JJ            J               can type 'J' when you need to


Making it easier to insert various kinds of braces:
  key combo     mapping         purpose
  JU            ()        easier to create parenthesis
  JI            []        easier to create square brackets
  JM            {}        eaiser to create curly braces
  J<<>        easier to create carrot braces


Make it easier to move small distances (especially useful with braces commands):
  key combo     mapping         purpose
  JL                      move left in insert mode
  JH                     move right in insert mode


Removing any need for enter, backspace or delete:
  key combo     mapping         purpose
  JB            ldbi       delete the previous word
  JW            dwi        delete the next word
  JO            oi         insert line and go to it

推荐阅读
  • Go GUIlxn/walk 学习3.菜单栏和工具栏的具体实现
    本文介绍了使用Go语言的GUI库lxn/walk实现菜单栏和工具栏的具体方法,包括消息窗口的产生、文件放置动作响应和提示框的应用。部分代码来自上一篇博客和lxn/walk官方示例。文章提供了学习GUI开发的实际案例和代码示例。 ... [详细]
  • Sleuth+zipkin链路追踪SpringCloud微服务的解决方案
    在庞大的微服务群中,随着业务扩展,微服务个数增多,系统调用链路复杂化。Sleuth+zipkin是解决SpringCloud微服务定位和追踪的方案。通过TraceId将不同服务调用的日志串联起来,实现请求链路跟踪。通过Feign调用和Request传递TraceId,将整个调用链路的服务日志归组合并,提供定位和追踪的功能。 ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • 1,关于死锁的理解死锁,我们可以简单的理解为是两个线程同时使用同一资源,两个线程又得不到相应的资源而造成永无相互等待的情况。 2,模拟死锁背景介绍:我们创建一个朋友 ... [详细]
  • sklearn数据集库中的常用数据集类型介绍
    本文介绍了sklearn数据集库中常用的数据集类型,包括玩具数据集和样本生成器。其中详细介绍了波士顿房价数据集,包含了波士顿506处房屋的13种不同特征以及房屋价格,适用于回归任务。 ... [详细]
  • 本文介绍了Web学习历程记录中关于Tomcat的基本概念和配置。首先解释了Web静态Web资源和动态Web资源的概念,以及C/S架构和B/S架构的区别。然后介绍了常见的Web服务器,包括Weblogic、WebSphere和Tomcat。接着详细讲解了Tomcat的虚拟主机、web应用和虚拟路径映射的概念和配置过程。最后简要介绍了http协议的作用。本文内容详实,适合初学者了解Tomcat的基础知识。 ... [详细]
  • 拥抱Android Design Support Library新变化(导航视图、悬浮ActionBar)
    转载请注明明桑AndroidAndroid5.0Loollipop作为Android最重要的版本之一,为我们带来了全新的界面风格和设计语言。看起来很受欢迎࿰ ... [详细]
  • 在Xamarin XAML语言中如何在页面级别构建ControlTemplate控件模板
    本文介绍了在Xamarin XAML语言中如何在页面级别构建ControlTemplate控件模板的方法和步骤,包括将ResourceDictionary添加到页面中以及在ResourceDictionary中实现模板的构建。通过本文的阅读,读者可以了解到在Xamarin XAML语言中构建控件模板的具体操作步骤和语法形式。 ... [详细]
  • 本文介绍了一款名为TimeSelector的Android日期时间选择器,采用了Material Design风格,可以在Android Studio中通过gradle添加依赖来使用,也可以在Eclipse中下载源码使用。文章详细介绍了TimeSelector的构造方法和参数说明,以及如何使用回调函数来处理选取时间后的操作。同时还提供了示例代码和可选的起始时间和结束时间设置。 ... [详细]
  • 带添加按钮的GridView,item的删除事件
    先上图片效果;gridView无数据时显示添加按钮,有数据时,第一格显示添加按钮,后面显示数据:布局文件:addr_manage.xml<?xmlve ... [详细]
  • Java图形化计算器设计与实现
    本文介绍了使用Java编程语言设计和实现图形化计算器的方法。通过使用swing包和awt包中的组件,作者创建了一个具有按钮监听器和自定义界面尺寸和布局的计算器。文章还分享了在图形化界面设计中的一些心得体会。 ... [详细]
  • 本文讨论了在使用Git进行版本控制时,如何提供类似CVS中自动增加版本号的功能。作者介绍了Git中的其他版本表示方式,如git describe命令,并提供了使用这些表示方式来确定文件更新情况的示例。此外,文章还介绍了启用$Id:$功能的方法,并讨论了一些开发者在使用Git时的需求和使用场景。 ... [详细]
  • 1简介本文结合数字信号处理课程和Matlab程序设计课程的相关知识,给出了基于Matlab的音乐播放器的总体设计方案,介绍了播放器主要模块的功能,设计与实现方法.我们将该设 ... [详细]
author-avatar
丫头2502934891
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有