How do I press and hold a key and have it repeat in VSCode?

The official vim-plugin for VS Code mentions how to set it up on macOS

defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false
defaults delete -g ApplePressAndHoldEnabled  # If necessary, reset global default

To disable the Apple press and hold for VSCode only, run this command in a terminal:

defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false

Then restart VSCode.

To re-enable, run this command in a terminal:

defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool true

The answer by Steve above didn't quite work for me because of global settings. It also left me curious about where to find the com.microsoft.VScode domain name for an app. Here is what worked for me and a generalized formulation:

To enable repeats for a specific app, like VSCode, first make sure that there isn't an overriding global setting.

defaults delete -g ApplePressAndHoldEnabled

Then enable the setting for the specific app, you can find the domain name of an app by finding it in the Info.plist document under the Contents folder where it is installed.

Example

<key>CFBundleIdentifier</key>
<string>com.microsoft.VSCode</string>

Then set the setting on the command line.

defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false

You can use this pattern other app specific settings as well. Just make sure that your settings aren't being overwritten globally.

For more information on defaults type defaults help. One more note, you don't need to run this as sudo if your user is already an admin.


You are on OSX, correct? If so, the issue might be Apple's "Press&Hold", where you can select alternative characters on long presses.

You can disable this "feature" with a defaults command in the terminal:

defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false

You have to restart VSCode afterwards.

To reenable the previous behaviour:

defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool true