Skip to main content

MacOS Vim Key Repeat Fix

·230 words·2 mins

When using Vim mode in editors like VSCode, Obsidian, or other applications on macOS, the navigation keys (h, j, k, l) may not repeat when held down. Instead, macOS shows an accent character menu, which breaks the expected Vim behavior.

The Solution
#

Disable the “press and hold” feature for specific applications using the Terminal:

For VSCode
#

defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false

For Obsidian
#

defaults write md.obsidian ApplePressAndHoldEnabled -bool false

For Any App (Global Setting)
#

defaults write -g ApplePressAndHoldEnabled -bool false

Finding Bundle Identifiers
#

To find the correct bundle identifier for any app:

# Quick method - replace "AppName" with the actual app name
osascript -e 'id of app "AppName"'

# Example for Obsidian
osascript -e 'id of app "Obsidian"'

Verify the Setting
#

Check if the setting was applied:

defaults read [bundle-identifier] ApplePressAndHoldEnabled

Should return 0 (false) if successful.

Important Notes
#

  • Restart the application after running the command
  • You may need to log out and back in to macOS for changes to take effect
  • To re-enable the feature, change -bool false to -bool true
  • The global setting affects all applications system-wide

Why This Happens
#

macOS prioritizes the accent character menu (for typing characters like é, è, ê) over key repetition. This feature is useful for typing in multiple languages but interferes with Vim’s navigation model, which relies on holding down movement keys.

Yilin Fang
Author
Yilin Fang
Ph.D. Student @ OSU CSE