How do I press and hold a key and have it repeat in VSCode?
Visual Studio-CodeVisual Studio-Code Problem Overview
I use the vim plugin and I typically scroll in vim by just holding j. In VSCode holding j just does a single j command, no matter how long it's held for.
Even in vanilla vscode this also doesn't work - problematic if you're trying to type long blocks of ########################### for comment separators. Any idea how to enable this functionality?
Visual Studio-Code Solutions
Solution 1 - Visual Studio-Code
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
Solution 2 - Visual Studio-Code
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
Solution 3 - Visual Studio-Code
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
Solution 4 - Visual Studio-Code
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.
Solution 5 - Visual Studio-Code
If you're on a mac and using VSCodium:
defaults write com.visualstudio.code.oss ApplePressAndHoldEnabled -bool false
Other answers targeting com.microsoft.VSCode
do not work because you're not running MS VSCode. The command default write
generates/updates files in ~/Library/Preferences/
appended with .plist
, you have to target the right file.
My software and versions:
macOS Mojave 10.14.6
VSCodium 1.41.1
- Vim (by vscodevim) 1.12.4 with neovim enabled
Neovim 0.4.3 Vim 8.1.2250
Solution 6 - Visual Studio-Code
Operating System : Mac
To enable key-repeating execute the following in your Terminal and restart VS Code:
$ defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false # For VS Code
$ defaults write com.microsoft.VSCodeInsiders ApplePressAndHoldEnabled -bool false # For VS Code Insider
$ defaults write com.visualstudio.code.oss ApplePressAndHoldEnabled -bool false # For VS Codium
$ defaults delete -g ApplePressAndHoldEnabled # If necessary, reset global default
We also recommend increasing Key Repeat and Delay Until Repeat settings in System Preferences -> Keyboard.
this is all in our readme https://github.com/VSCodeVim/Vim/blob/master/README.md#mac-setup
Solution 7 - Visual Studio-Code
For those of you on VS Code Insiders, just change the Bundle identifier to:
defaults write com.microsoft.VSCodeInsiders ApplePressAndHoldEnabled -bool false
Solution 8 - Visual Studio-Code
None of the above worked for me with my new laptop, instead I had to use:
defaults write -g ApplePressAndHoldEnabled -bool false
Solution 9 - Visual Studio-Code
The best answer from Steve doesn't work for my mac 'defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false', however below works for me:
sudo defaults write -g ApplePressAndHoldEnabled -bool false
reference: https://github.com/VSCodeVim/Vim/issues/345
Solution 10 - Visual Studio-Code
Though I reset with above mentioned commands and even after reboot, Once I open VSCode they are getting reset, so I had 'code' script to set them back every time I open VSCode editor.$ cat code VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* & defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false defaults delete -g ApplePressAndHoldEnabled