I'm trying to trigger (to use) the IdeaVim multi cursor plugin: https://github.com/JetBrains/ideavim#emulated-vim-plugins -> multiple-cursors
In the github docs we have commands: <A-n>
, <A-x>
, <A-p>
, g<A-n>
to trigger/use this plugin, but I'm not able to make this plugin working at all...
I've added in my .ideavimrc set multiple-cursors
.
Am I missing something?
I'm using OSX (if that's important).
A common way to add more cursors is with Shift+Alt+Down or Shift+Alt+Up that insert cursors below or above. Note: Your graphics card driver (for example NVIDIA) might overwrite these default shortcuts. Ctrl+D selects the word at the cursor, or the next occurrence of the current selection.
As mentioned in other answers, macOS treats <A-n>
as a "dead key" in order to enter accented characters, such as ñ
(<A-n>n
). It doesn't seem possible to disable this programmatically, and you have to use an alternative keyboard input source to work around this.
However, the <A-n>
keys are not the keys used by the extension that IdeaVim's multiple-cursors
is based on (terryma/vim-multiple-cursors). I'm not sure where they came from, but vim-multiple-cursors uses <C-n>
, <C-p>
and <C-x>
and only uses <A-n>
to select all occurrences, which is different to the IdeaVim behaviour. There is an issue tracking the wrong key mappings - VIM-2178.
In the meantime, you can remap the keys to match the Vim plugin by adding the following to your ~/.ideavimrc
:
" Remap multiple-cursors shortcuts to match terryma/vim-multiple-cursors nmap <C-n> <Plug>NextWholeOccurrence xmap <C-n> <Plug>NextWholeOccurrence nmap g<C-n> <Plug>NextOccurrence xmap g<C-n> <Plug>NextOccurrence nmap <C-x> <Plug>SkipOccurrence xmap <C-x> <Plug>SkipOccurrence nmap <C-p> <Plug>RemoveOccurrence xmap <C-p> <Plug>RemoveOccurrence
And you can work around the <A-n>
issue for "select all occurrences" by mapping to something else, such as Shift+Ctrl+n:
" Note that the default <A-n> and g<A-n> shortcuts don't work on Mac due to dead keys. " <A-n> is used to enter accented text e.g. ñ nmap <S-C-n> <Plug>AllWholeOccurrences xmap <S-C-n> <Plug>AllWholeOccurrences nmap g<S-C-n> <Plug>AllOccurrences xmap g<S-C-n> <Plug>AllOccurrences
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With