Tip: Easy on your fingers

I am getting some pain on my fingers, and since we type ( and ) quite often in prolog, I found a way to make it a little easier on my fingers. I now type ( and ) without the shift key.

Perhaps it will be useful for some of you. This works only on Linux, don’t know about other OSes.

  • Install xmodmap for your distro
  • Write ~/.xmodmap with this content:
!  Change parens, brackets, and braces
! Original settings
! -----------------
! keycode  18 = 9 parenleft 9 parenleft leftsinglequotemark dead_breve leftsinglequotemark
! keycode  19 = 0 parenright 0 parenright rightsinglequotemark dead_abovering rightsinglequotemark
! keycode  34 = bracketleft braceleft bracketleft braceleft guillemotleft leftdoublequotemark guillemotleft
! keycode  35 = bracketright braceright bracketright braceright guillemotright rightdoublequotemark guillemotright

! Change ( to {  and  ) to }
keycode  18 = 9 braceleft 9 braceleft leftsinglequotemark dead_breve leftsinglequotemark
keycode  19 = 0 braceright 0 braceright rightsinglequotemark dead_abovering rightsinglequotemark

! Change { to [  and  } to ]
!        [ to (  and  ] to )
keycode  34 = parenleft bracketleft parenleft bracketleft guillemotleft leftdoublequotemark guillemotleft
keycode  35 = parenright bracketright parenright bracketright guillemotright rightdoublequotemark guillemotright
  • run xmodmap ~/.xmodmap
  • Now you can type the parenthesis by pressing [ and ] without the shift key
  • It takes a while to get used to the new mapping, but it is worth it for me.

NOTE: If you want you can store the old keymap by running xmodmap -pke > ~/.original_keymap before making tha changes above. You can restore it by running xmodmap ~/.original_keymap. You can use this in a shell script if you want to change the parenthesis only when you run swipl.

Good idea! Most of my work is in Clojure, so I’ve also found remapping the paren keys to something easier vital for hand health. Something similar that I did (before switching to a keyboard that let me do even more remappings) was use the xcape program to make left & right shift act as normal shift keys when held, but when tapped would produce left & right parens.

Config for that was simply putting xcape -e 'Shift_L=parenleft;Shift_R=parenright' in my ~/.xsessionrc.

1 Like

I never thought about remapping the shift keys, that’s a good idea! Thanks for the tip!

1 Like

Nice idea, and added to my Xmodmap. Seems much more fluid for typing. Thanks for sharing.

Having worked with @swi’s .Xmodmap for a while, enjoying the ease of typing parenthesis, I started getting annoyed having to reach for the new location of the curly braces when language hopping, plus other far-away but common punctuation like - _ + = \ . I opted for something a little more extreme, putting much of the “out-of-reach” punctuation under the left hand, which took some time to get used to but is proving rather nice. Writing Prolog we do use far more punctuation than you would during word processing, and a greater variety too. I find this less stressful on the right-hand and faster to type with a standard layout keyboard.

I have my right-Alt key as the third-level select on the keyboard, easy to reach with the right pinky when you get used to it, not dissimilar from hitting shift. From there I set the braces up on the third level in the column made from WE SD XC keys. The top row are curly braces, the middle are the parenthesis, and the bottom are the square brackets. So to type () I hold down “R-Alt” and type “SD”.

Then I started to expand around it. Given how often we type ) :- I decided to put the colon on F and minus on G, so now that sequence is “R-Alt+(D, Space, F, G)”, it rolls quite nicely. Two other common sequences that force departure from the home-row are \= and \+. On UK keyboards, we tend to have the bar and backslash key between Z and left shift, but I use a US layout. So I put the backslash and bar onto the Z key with third level select and third level plus shift. With - on G, I wanted the other mathematical symbols under the same finger, so that put + on R and = on V. So now \+ is “R-Alt+(ZR)” and \= is “R-Alt+(ZV)”.

Here’s the relevant part of my .Xmodmap if you’d like to give left-hand punctuation a go. This doesn’t change the original punctuation keys so they’ll still work as marked.

!   Lefthand Punctuation
! top row
keycode 24 = q Q q Q asciitilde grave
keycode 25 = w W w W braceleft
keycode 26 = e E e E braceright
keycode 27 = r R r R plus
! middle row
keycode 39 = s S s S parenleft guillemotleft
keycode 40 = d D d D parenright guillemotright
keycode 41 = f F f F colon semicolon
keycode 42 = g G g G minus underscore
! bottom row
keycode 52 = z Z z Z backslash bar
keycode 53 = x X x X bracketleft leftanglebracket
keycode 54 = c C c C bracketright rightanglebracket
keycode 55 = v V v V equal

That’s great. I am glad it is making it much easier to type.