Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

ideavim

I've recently gotten into vim in a big way (again), and I now have a ton of customization in my .vimrc file. I realize that not everything in there would make sense in the context of an IDEA plugin, but I'd really like it if things like remapping jj to Esc were picked up and honored. Is there a way to do that? Without needing to manually tweak all that stuff in IDEA's keymap, that is.

Thanks.

like image 389
Hank Gay Avatar asked Apr 07 '11 18:04

Hank Gay


People also ask

Does IdeaVim use Vimrc?

vimrc. But IdeaVim doesn't support that. It does, however, support :set visualbell . Even though it doesn't flash the screen as you'd expect.

How do I enable IdeaVim?

Install the IdeaVim pluginIn the Settings/Preferences dialog ( Ctrl+Alt+S ), select Plugins. Find the IdeaVim plugin in the Marketplace and click Install. Restart IntelliJ IDEA.

Where do I put my Vimrc file?

The global or system-wide vim configuration file is generally located under the /etc/vim/vimrc . This configuration file is applied to all users and when Vim is started this configuration file is read and Vim is configured according to this file contents.


3 Answers

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.)

like image 196
jbyler Avatar answered Nov 16 '22 01:11

jbyler


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/

like image 24
ars-longa-vita-brevis Avatar answered Nov 16 '22 02:11

ars-longa-vita-brevis


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
like image 43
Alan Zhiliang Feng Avatar answered Nov 16 '22 00:11

Alan Zhiliang Feng