Is there a way to get IdeaVIM to honor the mappings from my .vimrc file?

Update: Yes! See answer below.

Short answer: no.

I've been trying to do this too especially because I have quite a complex .vimrc that I've become used to over the years.

Anyway, there is a workaround (sort of). IdeaVim settings are stored in a file called vim.xml in the .IntelliJIdea10/config/keymaps folder inside your home folder (C:\Users\<user_name> on Windows). You can edit the XML to add stuff that you want. For instance, I added the following lines to save a file by hitting F2 instead of typing :w!:

<action id="SaveAll">
<keyboard-shortcut first-keystroke="F2"/>
</action>

However, I don't see how we can add things like functions or vim settings (which is what I'd typically use a .vimrc for).

P.S. This might explain why a .vimrc is not used (emphasis mine):

For the curious, the plugin is being written without any reference to the VIM source code (except for the regular expression handling). I'm basically using the excellent VIM documentation and VIM itself as a reference to verify correct behavior.
Source: http://ideavim.sourceforge.net/


It looks the IdeaVIM issue # VIM-288 (edit, update: see jbyler's answer, VIM-288 now fixed) will solve your problem when that gets fixed. I, too, was looking for a way to have 'jk' exit insert mode instead of using the Escape key. I'm no expert on IntelliJ plugins, but I managed to modify the IdeaVIM source code so that the 'jk' shortcut was hardcoded in there. All I had to do then was re-deploy the plugin and use that instead of the official version. Here's how I did it:

  1. Grab the IdeaVIM source code.

    https://github.com/JetBrains/ideavim

  2. You can follow the instructions under "Development" on that page to set up your dev environment for the plugin.

  3. Now that your IdeaVIM project is all setup, open this file: com.maddyhome.idea.vim.key.RegisterActions.java

  4. It seems this file has all the Visual/Insert/Normal mode commands and their corresponding key-bindings. For my example of changing the "exit insert mode" key bind, Look for "VimInsertExitMode". You'll need to add a line to this block of code for your new shortcut.

  5. Here is how the section of code looked after I edited it:

    parser.registerAction(KeyParser.MAPPING_INSERT, "VimInsertExitMode", Command.Type.INSERT, new Shortcut[]{
        new Shortcut(KeyStroke.getKeyStroke('[', KeyEvent.CTRL_MASK)),
        new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK)),
        new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)),
        new Shortcut("jk"),
        new Shortcut(new KeyStroke[]{KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, KeyEvent.CTRL_MASK),
            KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)})
    });

  6. Now deploy the project (make a .jar) and add it to your plugins folder; I followed these instructions for reference:

    http://confluence.jetbrains.com/display/IDEADEV/Getting+Started+with+Plugin+Development#GettingStartedwithPluginDevelopment-anchor5

  7. You might need to save your Vim.xml file from your keymaps folder, I'm not sure. I deleted mine and then it was re-made when I restarted IntelliJ.

  8. Give it a whirl! Should be able to use 'jk' as your exit insert mode shortcut now!


Updated answer: IdeaVim version 0.35 (released 2014-05-15) reads settings and key bindings from ~/.ideavimrc. You can put source ~/.vimrc in that file if you want to include mappings from ~/.vimrc.

0.33 and 0.34 read ~/.vimrc directly.

0.33 (released 2014-04-28) was the first version to implement VIM-288, including things like mapping jj to ESC. It works great, and there's a new Vim Emulation section in the IDEA preferences that lists all the conflicts between ~/.vimrc mappings and Intellij mappings, and lets you resolve the conflicts by assigning the keys to either IDEA or IdeaVim. Here is the release announcement on twitter.

(Note: I'm not the author, just a satisfied user.)


According to the description in the repository of the plugin (https://github.com/JetBrains/ideavim), you can achieve that by create a file "~/.ideavimrc" with its content:

source ~/.vimrc

Tags:

Vim

Ideavim