Configuring .ideavimrc

Daniel Díaz Carrete
4 min readApr 28, 2018

This is my current .ideavimrc.

Shortcut conflicts

IntelliJ IDEA shortcuts and Vim shortcuts conflict in some places. I prefer to keep the IDEA shortcuts most of the time, except for the following:

  • Ctrl-[ It’s “Move Caret to Code Block Start” in IDEA, but too valuable as an Esc key alternative in Vim.
  • Ctrl-] “Move Caret to Code Block End” in IDEA, but better as “Jump to definition” in Vim.

For curly bracket languages, [{ and ]} can be used as Vim-native alternative to IntelliJ’s Ctrl-[ and Ctrl-].

  • Ctrl-V “Paste” in IDEA, but better as “enter block-visual mode” in Vim.
  • Ctrl-R “Replace” in IDEA, “Redo” in Vim.
  • Ctrl-W “Extend selection” in IDEA, but lets you switch between split windows in Vim’s normal mode, and also deletes the last word in Vim’s insert mode. Doubtful about this one, “Extend selection” looks useful…
  • Ctrl-H “Type hierarchy” in IDEA, but lets you delete the last char in Vim’s insert mode without reaching all the way to Backspace. Doubtful about this one, too.
  • Ctrl-O “Create listener” in IDEA, backwards in the Jump List in Vim.
  • Ctrl-I “Implement methods” in IDEA, forwards in the Jump List in Vim.
  • Ctrl-M “Commit message history” in IDEA, but lets you avoid having to reach all the way to Enter in Vim’s insert mode.
  • Ctrl-L “Next occurrence” in IDEA, nothing important in Vim. Put some useful binding here.
  • Ctrl-S “Save all” in IDEA, nothing important in Vim. Put some useful binding here.
  • Ctrl-D “Duplicate line” in IDEA. Not that useful by itself, and easily done from within Vim (Yp).
  • Ctrl-K “Commit” in IDEA. Not that frequent an action.

Remapped actions

I bound some frequent actions to new Vim shortcuts, because the IntelliJ native ones were cumbersome or collided with existing Vim shortcuts:

  • RenameElement IDEA shortcut uses function keys, too far from home row!
  • FileStructurePopup IDEA shortcut uses function keys, too far from home row!
  • GotoImplementation Awkward three-key shortcut.
  • EditorSelectWord This corresponds to the “Extend Selection” action originally bound to Ctrl-W in IDEA. Sadly, it doesn’t seem to interact well with Vim commands. (Since 0.52, it does.)
  • TypeHierarchy I want to use Ctrl-H in Vim’s insert mode, but I want it to perform its default IDEA action for normal mode, so I re-defined that action from within Vim.
  • $Paste I want to use Ctrl-V in Vim’s normal mode, but I want it to perform its default IDEA action for insert mode, so I re-defined that action from within Vim.
  • JumpToLastChange Bound to Ctrl-Shift-Backspace in IDEA, which is actually not that bad.

See :actionlist for all the available actions.

Jumping around

The behaviour of the standard Ctrl-O and Ctrl-I actions feels a bit off in IdeaVim, in a way I can’t quite pinpoint. It’s not IntelliJ’s default Back and Forward behaviour, but it isn’t Vim’s, either. I think emulating Vim’s behavior faithfully would be complicated: the Vim jumplist always works in the current window, while IntelliJ will jump to an already open tab if you follow a definition.

So I decided to fully adopt IntelliJ’s behaviour for recent jumps and changes, but using Vim’s shortcuts:

  • Ctrl-O remapped to Back action.
  • Ctrl-I remapped to Forward action.
  • g; remapped to JumpToLastChange action.
  • g, remapped to JumpToNextChange.

IntelliJ bindings that work fine

Menu-based IntelliJ bindings

Rather than use the function keys, or some combinations that are hand-stretching, or hidden by my Vim mappings, I sometimes go through the menu shortcuts:

  • Alt+N, K, B to toggle bookmarks instead of F11.
  • Alt+N, K, S to show bookmarks instead of Shift+F11. Bookmarks can also be seen in “Favorites” by typing Alt+2.
  • Alt+N, R to go to related symbol, instead of Ctrl+Alt+Home.
  • Alt+N, S to symbol search, instead of Ctrl+Alt+Shift+N.
  • Alt+E, F, R to replace instead of Ctrl+R.
  • Alt+R, R to rename instead of Shift+F6.
  • Alt+B, E to recompile current class instead of Ctrl+Shift+F9.

Vimmy things that work

  • Splitting windows horizontally and vertically, switching between them with Ctrl-W.
  • Moving between editors with gt and gT.
  • Opening and closing existing folds with zc and zo.
  • [[, ]], ‘[, ‘], ‘^, gi.
  • Visual mode seems to work.
  • Marks seem to work. (Since 0.52, there is the ideamarks option which integrates uppercase marks and regular IntelliJ bookmarks.)
  • Registers seem to work.
  • Surround-like functionality, if you activate it.
  • (Since 0.52) Commentary-like functionality, if you activate it.
  • (Since 0.52) Select mode. Used mostly in the rename refactor.
  • Digraphs.
  • gn command (Since 0.52, more complete support).
  • J command (Since 0.52, it can do cool IntelliJ-specific things if the ideajoin option is set).
  • The relativenumber and number options.

Here’s the full list of supported commands.

Vimmy things that are missing

Configuring true Vim as an external tool

gvim can also be configured as an external tool. Pass the $FilePath$ argument and check Synchronize files after execution.

You can assign an IDEA shortcut (perhaps Alt-X?) to it in the Keymap.

--

--