Skip to main content
4 of 4
added 2 characters in body
saginaw
  • 6.9k
  • 2
  • 27
  • 47

Sticky shift - or getting <shift> with letter combinations

I use the shift keys a lot and it is an unnecessary strain on the pinky. The enter and backspace functionalities are conveniently located under a dominant finger (ctrl-m and ctrl-h). Similarly:

Is there a way to map the shift function to a dominant finger?

But in the vim spirit I want to get this functionality with a key combination rather than finger acrobatics; e.g., lets use the extremely rare key combination fd (in insert mode!).

For the alphanumerical keys one could dump an entire list of imaps: fd1 !, fd2 @, ..., fda A etc. into vimrc. I'm hoping there is a better way.

Ideally, fd would be mapped to a "sticky shift" that waits for a one letter input, shifts it, then turns off the sticky shift. Is this possible?

Many thanks!

Post mortem

Rich has a function down below which can be modified to have the complete effect. Last night someone wrote a neat solution and then erased it so I will include it here:

imap <expr> fd nr2char(getchar()-32)

This does the trick if all you want to capitalize letters. Otherwise it seems like a good way to do function calls.

Another good suggestion in the comments below is modifying the keyboard at the firmware level using this.

Thanks for the help everyone!

Emre
  • 217
  • 1
  • 5