Fix Vim Mode Repeating Keys on Mac OS X


If you use Vim mode in the editor of the RStudio Desktop IDE on Mac OS X, you may find that holding down the cursor keys in command mode (h, j, k, and l) doesn't cause the keys to repeat, which can make navigation difficult.

This behavior is caused by the ApplePressAndHoldEnabled default. The safest way to work around the problem is to remove the global default (if any) and set the default for RStudio to false. You can do this by executing the following commands in a Terminal window:

defaults delete -g ApplePressAndHoldEnabled
defaults write -app RStudio ApplePressAndHoldEnabled -bool false

The first command may emit a warning if there is no global default set; this is ignorable.

Alternatively, if you want to enable repeating keys for all the apps on your system (including RStudio), you can set the preference globally:

defaults write -g ApplePressAndHoldEnabled -bool false

You'll need to restart the RStudio IDE after running these commands to pick up the new defaults.