alols / xcape

Linux utility to configure modifier keys to act as other keys when pressed and released on their own.
GNU General Public License v3.0
2.1k stars 117 forks source link

xcape + vim + tmux #49

Closed esn89 closed 8 years ago

esn89 commented 9 years ago

Hi,

With xcape running in my .zshrc like so: setxkbmap -option 'caps:ctrl_modifier' xcape -t 50 -e 'Caps_Lock=Escape'

I seem to be able to get it work on normal behavior such as browsing the internet, copying things from my terminal and copying and pasting all using the Caps Lock key. I am even able to switch panes in tmux.

However, when I use vim within tmux and I want to switch to normal mode, pressing Caps Lock doesn't work. Anyone know why?

Ran4 commented 8 years ago

I'm not entirely sure why it works, but I'm using the same combination of xcape+vim+tmux and I solved it by adding these lines to my .vimrc:

set timeout
set timeoutlen=2500
set ttimeoutlen=10

I think that this has to do with Vim waiting for another key to be pressed (e.g. pressing the physical caps key sends a ^[ key, which causes Vim to wait for you to press another key such as a to turn it into ^[a).

Vim won't receive the other key though, instead waiting forever. By activating timeout, and setting the ttimeoutlen value, Vim will accept the single ^[ as an escape after the timeout (which is set to 10 ms here).

The timeoutlen variable is used for multi-character commands, e.g. if this is set to 1000 and you press g, wait 1001 ms and press g again, then two single g commands will be performed (neither doing anything, as g is not a vim command), as opposed to the gg command. You might want to consider a value that's slightly lower than 2500.