33

I would really like to be able to use IdeaVIM but I am unable to figure out where I can set my custom vim key mappings. For example instead of using Esc I would like to use Ctrl-C and instead of using hjkl I like to use wasd.

I have all these already set in my .vimrc but IdeaVIM failed to load them. I can copy them over manually to whatever file is needed but there is no documentation on how to do this.

hsz
  • 136,835
  • 55
  • 236
  • 297
gdoubleod
  • 1,138
  • 3
  • 15
  • 32
  • 1
    The [IdeaVim FAQ](http://ideavim.sourceforge.net/faq.php) seems to address this. – Nolen Royalty Apr 13 '12 at 23:21
  • Hi I looked at that link before I posted and also looked at the Vim.xml and couldn't figure out how to change the key mappings. I need to change the movement keys so I searched that Vim.xml file for j and couldn't find anything. Could you give me an example of a simple key mapping? thanks – gdoubleod Apr 15 '12 at 03:26
  • Please vote for the feature request [VIM-288](http://youtrack.jetbrains.com/issue/VIM-288): Support key mapping commands from `.vimrc`. – Andrey Vlasovskikh Dec 30 '12 at 10:10
  • I'm new to IdeaVim, but it could be that the IDE is handling the keystrokes, not IdeaVim? If you want to change how that's done, you can manage "Vim Emulation" settings in `File | Settings | Editor | Vim Emulation` on PC, or `Settings | Editor | Vim Emulation` on Mac – Brad Parks Jun 20 '19 at 11:39

4 Answers4

33

As of IdeaVim 0.35 (released 2014-05-15), key mappings in ~/.ideavimrc are supported. You can put source ~/.vimrc in that file if you want to include mappings from ~/.vimrc.

Release announcement

VIM-288

(Note: This question could probably be considered a duplicate of this other StackOverflow question.)

Community
  • 1
  • 1
jbyler
  • 6,013
  • 3
  • 27
  • 36
  • if you don't have the file ~/.ideavimrc then you can just simply create it. Just write `source ~/.vimrc` or source wherever your .vimrc file is. Restart pycharm. – SanD Mar 08 '18 at 11:26
  • 2
    On Windows, .ideavimrc should live in C:\Users\%USERNAME%\ – Lorem Ipsum Aug 30 '18 at 15:57
31

I've done this myself, and its pretty easy in IntelliJ 11. I know that in previous versions (9, maybe?) setting up keymap values is significantly different.

In IntelliJ 11 you can do the following:

  1. Go to Settings
  2. Select Keymap from the left menu
  3. Search for Exit Insert Mode on the right side and associate whatever key you want to use, such as CTRL-C
trentcl
  • 17,886
  • 5
  • 37
  • 60
dsummersl
  • 5,938
  • 46
  • 63
  • 2
    Nice! The one weird thing I see is that all of the keys are on one line. It says keys and then one long string... does your's look like that? – gdoubleod May 04 '12 at 02:37
  • 21
    @gdoubleod: Mine looks like that, too. I really wish I could use 'jk' as my esc in ideavim. If I try to make it a two-stroke gesture, it just breaks j in normal mode. – danneu Dec 15 '12 at 14:55
  • 1
    @danneu: There is currently an [issue](http://youtrack.jetbrains.com/issue/VIM-518) on the JetBrains' bug tracker addressing precisely this problem. Vote up! – gregoltsov Oct 17 '13 at 14:52
  • 7
    I use `jj` to exit insert mode. Creating a keymap using this method prevents the practical use of `j` in normal mode (such as trying to go down by three lines `jjj`). To avoid this, create `.ideavimrc` and put `:imap jj ` into it. – Lorem Ipsum Aug 30 '18 at 16:00
  • Another popuplar option is `:imap jk ` – dsummersl Aug 30 '18 at 17:59
2

IntelliJ 12.1:

  1. Go to Settings
  2. Select Keymap from the left menu
  3. Find Escape under the Editor Actions section and add the Ctrl-C shortcut there. ("Escape" under the "IdeaVim" section didn't work for me)

Following the same steps, but replacing "Escape" with "Exit Insert Mode" only partially worked for me. It exited insert mode correctly but ignored the following keystroke. So typing Ctrl-C,j,j would exit insert but only go up one line instead of two.

Ivan Aracki
  • 3,668
  • 8
  • 47
  • 63
1

If you like to have Vim plugin installed (I find it very handy for typing) and at the same time have Ctrl+C and Ctrl+V working for copy and paste actions, do the following:

In the IntelliJ Idea, click on File > Setting. On the left pane, expand Editor and click on Vim Emulation.

Here, under the Shortcut column, find Ctrl+C and change it's Handler (under Handler column) to IDE instead of Vim.

Repeat it for Ctrl+V as well and hit Apply and Ok.

Now, you should be able to use the keyboard shortcuts for copy and paste while keeping the Vim Emulator enabled.

PhantomReference
  • 618
  • 1
  • 12
  • 25