[Vim] Chording keys to type faster and avoid RSI

Правка en1, от z4120, 2019-11-29 17:11:20

It's not uncommon for people here to try to improve their typing speed, or to complain that programming requires typing some hard-to-type characters frequently. There are a few solutions to that:

  • Buy an ergonomic keyboard model. May work, but will not be discussed here.
  • Just practice (on typeracer, etc.) This may help with the speed, but typing special symbol is still hard.
  • Use alternate keyboard layout: may not always be available in on-site programming contests. In particular, Programmer Dvorak layout is not available on Windows by default.
  • Key chording: discussed below.

While there are just so many keys on the keyboard, you can "make" more by chording the key (taking the idea from stenography). Then you can bind those to commonly typed keys/sequences.

  1. How to bind keys?

    Vim supports key binds natively. Just use noremap! (or just map!) I don't know if you don't use Vim.

  2. What key bindings do you use?

    ws = <bs>, uj = (, ik = ), UJ = [, IK = ], df = 0, un = unsigned, jp = .push_back(, jk = <<, as; = sa; = <esc>, fj = jf = <cr>, and some other ones.

  3. Isn't that a lot? Would it be very slow to type them during programming competitions?

    map! jp .push_back( is shorter than #define pb push_back. For brackets/special characters, it makes typing faster, so it's worth it.

  4. Would typing two/three keys be slower than one key?

    Typing shift+some key is not faster than typing two keys. Also, for key mappings that uses the same finger (such as uj or ik) you only need to press once. (I use some key cap to make it possible to press multiple keys with a single finger)

  5. Does this really matter? My typing speed is fast already.

    I think this is better ergonomically.

  6. What if I get the order of the key wrong?

    For chords typed with one finger that's not a problem. For others, a workaround is to use some plug-in (vim-arpeggio, for example) (not available in on-site contests), or to bind all permutations (not really feasible for combinations longer than 2 characters)

  7. Can they cause conflict with something else?

    It depends. Sometimes I get conflicts, but you can analyze your existing code to see if a combination is okay, or rename the variables (instead of rows you can use rowz for example)

  8. What about #define?

    Then you'll need to type parentheses anyway.

Теги typing, speed

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский z4120 2019-11-29 17:11:20 2448 Initial revision (published)