24

我正在尝试触发(使用)IdeaVim 多光标插件:https ://github.com/JetBrains/ideavim#emulated-vim-plugins -> multiple-cursors

在 github 文档中,我们有命令:<A-n>, <A-x>, <A-p>,g<A-n>来触发/使用这个插件,但我根本无法让这个插件工作......

我已经添加到我的 .ideavimrc 中set multiple-cursors

我错过了什么吗?

我正在使用 OSX(如果这很重要)。

4

3 回答 3

22

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
于 2020-12-23T20:25:49.803 回答
21

是的,tnx 提醒我!

实际上,现在在 OSX Mojave 中,我们可以Unicode Hex Input在键盘输入源中选择在此处输入图像描述

就是这样......现在一切正常,特殊字符在(alt / option +)输入上被禁用,我可以毫无问题地使用所有快捷方式:)

于 2019-03-18T12:15:58.813 回答
4

OSX 具有映射到option+ key的特殊字符。例如,您应该使用它禁用它们。

之后写下这段文字:

Hello world!
Hello world!
Hello world!
Hello world!

插入插入符号Hello并按<A-n>几次。Hello应该为每个单词选择一个单独的插入符号。

于 2019-03-18T09:09:13.683 回答