37

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.

5
  • 1
    The IdeaVim FAQ seems to address this. Apr 13, 2012 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, 2012 at 3:26
  • Please vote for the feature request VIM-288: Support key mapping commands from .vimrc. Dec 30, 2012 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, 2019 at 11:39
  • Yooo IdeaVim is soo much better than VSCode's Vim offerings. So many more features just frickin work! Feb 27 at 19:41

4 Answers 4

34

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

2
  • 1
    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 8, 2018 at 11:26
  • 3
    On Windows, .ideavimrc should live in C:\Users\%USERNAME%\ Aug 30, 2018 at 15:57
33

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
5
  • 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 4, 2012 at 2:37
  • 22
    @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, 2012 at 14:55
  • 1
    @danneu: There is currently an issue on the JetBrains' bug tracker addressing precisely this problem. Vote up!
    – gregoltsov
    Oct 17, 2013 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 <Esc> into it. Aug 30, 2018 at 16:00
  • Another popuplar option is :imap jk <Esc>
    – dsummersl
    Aug 30, 2018 at 17:59
6

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.

1
  • I couldnt find that option anywhere, lol.... thanks for pointing it out!
    – Brad Parks
    Jul 30, 2021 at 18:57
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.