10

I'm using IntelliJ IDEA 14.1.4 Community Edition in Mac OS Yosemite 10.10.5.

I already know about the global ApplePressAndHoldEnabled fix:

defaults write -g ApplePressAndHoldEnabled -bool false

But I want to disable it only for IntelliJ IDEA, and none of these commands work when using the "IdeaVim" plugin with Scala (With restarting IDEA):

defaults write com.jetbrains.intellij.ce ApplePressAndHoldEnabled -bool false
defaults write com.jetbrains.intellij ApplePressAndHoldEnabled -bool false
defaults write com.jetbrains.AppCode ApplePressAndHoldEnabled -bool false

Or any of the other commands listed here.

How do you disable ApplePressAndHoldEnabled for a specific application?

Neil
  • 24,551
  • 15
  • 60
  • 81
  • 1
    were you able to solve this problem by any chance? This drives me crazy and none of the default domains work – oiavorskyi Feb 17 '16 at 01:23
  • See the canonical, complete solution to this problem, here: https://stackoverflow.com/a/70911250/14193 – Neil Jan 30 '22 at 02:02

3 Answers3

9

Here is the canonical, complete solution to this problem:

Settings for ApplePressAndHoldEnabled:

The boolean values of the ApplePressAndHoldEnabled Mac OS defaults correspond to the following settings:

  • true => show-character-accents-menu: Holding a keyboard key down will bring up a character modification menu like so: Character accent menu for the "e" character
  • false => repeat-character-while-key-held: Holding a keyboard key down will repeat that key continuously, after a delay, until the key is released: Key repeating animation

How to set show-character-accents-menu behaviour globally by default, but repeat-character-while-key-held behaviour per-application:

  1. The ApplePressAndHoldEnabled default must be unset globally (rather than being set to true or false), with the following command:
defaults delete -g ApplePressAndHoldEnabled    # Unset globally
  1. The ApplePressAndHoldEnabled default must be set to false for each application for which you wish to set the repeat-character-while-key-held behaviour, with the following command:
defaults write "$APP_ID" ApplePressAndHoldEnabled -bool false

Where $APP_ID is something like com.jetbrains.intellij.ce for "IntelliJ IDEA Community Edition".

Paste this code in the terminal to set the repeat-character-while-key-held behaviour for all IntelliJ IDEs, but set show-character-accents-menu behviour globally:

KEY='ApplePressAndHoldEnabled' \
&& defaults delete -g "$KEY" \
; echo \
&& APP_ID_PREFIX='com\.jetbrains\.' \
&& defaults read | egrep -o "${APP_ID_PREFIX}[^\"]+" | sort --unique \
| while read APP_ID; do
    echo "Setting \"repeat-character-while-key-held\" for application: '$APP_ID'..."
    defaults write "$APP_ID" "$KEY" -bool 'false'
done

Checking global and app-specific set values of ApplePressAndHoldEnabled:

Values can be checked like this:

defaults read -g        ApplePressAndHoldEnabled    # Global
defaults read "$APP_ID" ApplePressAndHoldEnabled    # Per-application

Paste this code in to the terminal to show the settings for ApplePressAndHoldEnabled globally and per-application:

KEY='ApplePressAndHoldEnabled'
APP_ID_PREFIX='com\.jetbrains\.' \
&& echo \
&& printf "%-30s %-20s %-8s\n" \
    "Application" \
    "Type" \
    "Value" \
&& printf "%-30s %-20s %-8s\n" \
    "$(printf -- '-%.0s' {1..30})" \
    "$(printf -- '-%.0s' {1..16})" \
    "$(printf -- '-%.0s' {1..8})" \
&& (defaults read | egrep -o "${APP_ID_PREFIX}[^\"]+" | sort --unique && echo '-g') \
| while read APP_ID; do
    printf "%-30s %-20s %-4s\n" \
    "${APP_ID}" "\
    $(defaults read-type "${APP_ID}" "$KEY" 2> /dev/null || echo '(unset)')" \
    "$(defaults read "${APP_ID}" "$KEY" 2> /dev/null || echo '(unset)')"
done \
&& echo

Where this is the expected output:

Application                    Type                 Value
------------------------------ ----------------     --------
com.jetbrains.WebStorm         Type is boolean      0
com.jetbrains.intellij         Type is boolean      0
com.jetbrains.intellij.ce      Type is boolean      0
com.jetbrains.pycharm          Type is boolean      0
-g                             (unset)              (unset)
Neil
  • 24,551
  • 15
  • 60
  • 81
  • Would there be a way to disable for specific keys only e.g. for using vim in a foreign human language and disabling for `h`, `j`,`k`, `l` keys only? – ilam engl Nov 29 '22 at 09:24
3

You can find the appropriate domain name by grepping the output of defaults:

defaults read | egrep -o 'com\.jetbrains\.\w+' | sort --unique

For IntelliJ Ultimate it gives me:

com.jetbrains.intellij
com.jetbrains.intellij-EAP

where the second one is for EAP builds of IntelliJ.

Neil
  • 24,551
  • 15
  • 60
  • 81
Andrey Vlasovskikh
  • 16,489
  • 7
  • 44
  • 62
  • This just gives you the list of defaults that are set, not the list of defaults that are possible. Running that on my machine gives me a list of domains that have no effect. – Neil Nov 04 '15 at 20:54
  • This is the first mention I've seen of a fix for the EAP edition. Been tearing my hair out over this, so thank you - particularly for the defaults tip. – Flic Jun 07 '18 at 04:31
  • See the canonical, complete solution to this problem, here: https://stackoverflow.com/a/70911250/14193 – Neil Jan 30 '22 at 02:02
2

As found in this SuperUser post, it may be necessary to delete the global default before the application-specific default will be visible.

defaults delete -g ApplePressAndHoldEnabled

After I did that and set an application-specific value for RubyMine...

defaults write com.jetbrains.rubymine ApplePressAndHoldEnabled -bool true

...I could use IdeaVim in RubyMine and still use the press and hold accent dialog in all other applications.

Jim Breen
  • 81
  • 3
  • See the canonical, complete solution to this problem, here: https://stackoverflow.com/a/70911250/14193 – Neil Jan 30 '22 at 02:01