How to configure in IdeaVIM Ctrl + N and Ctrl + P completion from Vim?
Solution 1
Alt + /
and Alt + Shift + /
work both in plain IntelliJ and with IdeaVim installed.
Please see documentation on JetBrains page - it's called Hippie Completion (newer versions call this completion Cyclic Expand Word).
And of course you can always use Ctrl + Space
, Ctrl + Shift + Space
, Ctrl + Alt + Space
.
Solution 2
I could not get CTRL-N and CTRL-P to work after mapping them to "Cyclic Expand Word" and "Cyclic Expand Word (Backward)" in IDEA 2016.2.5 (while running IdeaVIM). Both keystrokes just did nothing.
The solution was to additionally select "Settings" from the File Menu, then "Other Settings" -> "Vim Emulation", and set the "Handler" for Ctrl+N and Ctrl+P to "IDE" instead of "Vim".
Solution 3
This is the way I found to make the word completion work with CTRL-N and CTRL-P, while still having the shortcuts work for DOWN and UP in lists.
In Settings -> Keymap, map CTRL-N and CTRL-P to Down and Up respectively. Then, in the Other Settings -> Vim Emulation, set CTRL-N and CTRL-P handlers to Vim.
Finally, add the following to your .ideavimrc
imap <C-n> <ESC>:action HippieCompletion<CR>a
imap <C-p> <ESC>:action HippieBackwardCompletion<CR>a
Solution 4
Add the following keymaps: Ctrl+N
to Down
and Ctrl+P
to Up
So you can easily navigate in the completions menus.
Solution 5
File->Settings->Keymap->search keywords "cyclic expand word"
Simon Su
Updated on June 15, 2022Comments
-
Simon Su almost 2 years
In Vim we can use
Ctrl + N
orCtrl + P
to finish code completion. How to configure it in IdeaVim for IntelliJ? -
Simon Su almost 9 yearsThianks a lot, it works. Do you know if there are any shortcut keys which can show a "list" like vim
-
Michal Kordas almost 9 years
Ctrl + Space
,Ctrl + Shift + Space
andCtrl + Alt + Space
are the only I know to show the list of completions. -
Ikar Pohorský over 8 yearsDid anyone manage to map
Ctrl + P
to behave the same asAlt + /
? I added new keyboard shortcut but hittingCtrl + P
does not work. There is no conflicting shortcut and I also tried to removeAlt + /
mapping. No success=( -
Michal Kordas over 8 years@IkarPohorský - It works for me without any problems in the latest EAP of IntelliJ 15.
-
Jason about 7 yearsThis is the correct answer for IDEA 2016.3.4. The second part of this answer - changing the handler from vim to ide - is the crucial step, but the keymap for cyclic expand word is also necessary as mentioned in other answers as well as this answer.
-
laike9m over 6 yearsYou're a genius.
-
Michael Scheper over 5 yearsThanks, but I don't think this is an acceptable answer. I've been using vim for over 25 years and use it daily in multiple environments, so having to use 'special' keys for everyday functions, just for this one environment, doesn't make IdeaVIM sound like a good emulator.
-
Michael Scheper over 5 yearsThat's assuming there is a 'completions' menu. The problem is when we're trying to auto-complete a string, e.g.
MY_ENV_VALUE = os.env["MY_ENV_VALUE"]
. In the real vim, Ctrl+P after the second capital M completes the required string. -
Parth Sharma about 5 years@IkarPohorský Did you finally figure out how to do it?
-
Ikar Pohorský about 5 years@ParthSharma: yup, see the answer from: softw
-
avivr over 4 yearsThis used to work perfectly. Now after some update of PyCharm/ideaVim (not sure which is the culprit), this doesn't work... It allows hippie completion (aka cyclic expand) but Up/Down in completion menus does no longer work. I tried multiple things but couldn't get both to work again. Any idea how to mkae both things work again?
-
haridsv about 3 yearsThis is working for me with no other changes (i.e.,
<C-p>
and<C-n>
handler is set to the default Vim). I am using IntelliJ2020.3.2
and IdealVim0.64
.