How to configure in IdeaVIM Ctrl + N and Ctrl + P completion from Vim?

12,363

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"

Share:
12,363
Simon Su
Author by

Simon Su

Updated on June 15, 2022

Comments

  • Simon Su
    Simon Su almost 2 years

    In Vim we can use Ctrl + N or Ctrl + P to finish code completion. How to configure it in IdeaVim for IntelliJ?

  • Simon Su
    Simon Su almost 9 years
    Thianks a lot, it works. Do you know if there are any shortcut keys which can show a "list" like vim
  • Michal Kordas
    Michal Kordas almost 9 years
    Ctrl + Space, Ctrl + Shift + Space and Ctrl + Alt + Space are the only I know to show the list of completions.
  • Ikar Pohorský
    Ikar Pohorský over 8 years
    Did anyone manage to map Ctrl + P to behave the same as Alt + /? I added new keyboard shortcut but hitting Ctrl + P does not work. There is no conflicting shortcut and I also tried to remove Alt + / mapping. No success=(
  • Michal Kordas
    Michal Kordas over 8 years
    @IkarPohorský - It works for me without any problems in the latest EAP of IntelliJ 15.
  • Jason
    Jason about 7 years
    This 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
    laike9m over 6 years
    You're a genius.
  • Michael Scheper
    Michael Scheper over 5 years
    Thanks, 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
    Michael Scheper over 5 years
    That'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
    Parth Sharma about 5 years
    @IkarPohorský Did you finally figure out how to do it?
  • Ikar Pohorský
    Ikar Pohorský about 5 years
    @ParthSharma: yup, see the answer from: softw
  • avivr
    avivr over 4 years
    This 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
    haridsv about 3 years
    This 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 IntelliJ 2020.3.2 and IdealVim 0.64.