Search code examples
ideavim

IdeaVim: Make Cmd-A (macOS) select all text in visual mode


I want Cmd-A (the macOS Command key, plus A) to select all text in visual mode, so I can e.g. indent or delete it using vim commands, Just like it does in MacVim. By default, it selects all text, but vim commands don't work on it.

I've put the following in .ideavimrc:

map <D-a> <esc>ggVG

And also removed the default Cmd-A shortcut in Preferences -> Keymap, because it seemed to override the vim one. But now Cmd-A just doesn't do anything.

I've found two workarounds so far, neither very satisfying. For both start out in normal-mode.

  1. ggVG
  2. press v followed by Cmd-A

Solution

  • <D-*> mappings are not supported in IdeaVim yet. Feel free to vote for VIM-758 and contribute a fix to https://github.com/JetBrains/ideavim.

    Edit: You can check your effective mappings in IdeaVim via :map.

    Edit 2: I've checked <M-*> mappings in IdeaVim 0.50 in macOS. They do exactly what you want, but with <M-*> instead of <D-*>. In my experiment, I've remapped dd to Command-A via:

    map <M-a> dd
    

    Important: the first time you open the IDE afterwards, there is a notification: "Using the shortcut from vim emulation. etc." Do not click the link in that notification, otherwise it will not use your shortcut defined in .ideavimrc.