I have been using IdeaVim for half a year, and it has significantly improved my coding efficiency by minimizing my reliance on the mouse. In this post, I’d like to share some commonly used configurations and walk you through my workflow for setting up IdeaVim.
IdeaVim is a Vim engine for JetBrains IDEs. You can find installation instructions in the official guide: JetBrains Plugin Management. Like other plugins, it can be easily installed. Along with IdeaVim, I highly recommend installing IdeaVim-EasyMotion and Which-Key for a better experience.
Once IdeaVim is installed, you’ll see the current mode displayed at the bottom right corner, and you can start enjoying Vim-style operations. All Vim configurations are managed in the
.ideavimrc file.However, plain IdeaVim only supports basic Vim operations. By adding EasyMotion, we gain the ability to navigate in multiple dimensions more efficiently. When IdeaVim is in Normal mode, you can press the leader key (which you configure yourself), and all the key mappings will switch to EasyMotion commands. For example, here’s how I set it up:
let mapleader = " " " use space as easy motion leader key nmap <leader>gg :action GenerateGetter
I set the spacebar
<Space> as my leader key. Pressing the leader key followed by gg (generate getter) is mapped to generate Java getters. When triggered, IntelliJ IDEA brings up a window like this::action GenerateGetter is an IntelliJ IDEA command that triggers the "Generate Getter" action. Most available actions can be found using the Search Everywhere feature in IDEA. To look up action IDs, switch to the Actions tab and enable Track Action IDs. Once enabled, when you use an action, IdeaVim will display its corresponding Action ID in the bottom-right corner. You can map any of these actions in your .ideavimrc file.Â
Which-Key is a plugin that helps you remember and discover key mappings in IdeaVim.
To enable it, add
pluginset which-key to your .ideavimrc file. Then configure it as follows:let g:WhichKeyDesc_Generate = "<leader>g generate" let g:WhichKeyDesc_Generate_GenerateGetter = "<leader>gg GenerateGetter"
Pressing the leader key followed by
g brings up a window like this:Â
NERDTree is another useful plugin that helps you browse and manage the project file directory. I’ve configured it as shown below, combining it with IdeaVim actions so you’ll never have to bother using the mouse to create files in your project. NERDTree is quite powerful — you can find more supported actions in the official IdeaVim wiki.
nnoremap <leader>nn :NERDTreeFocus nmap <leader>nd <action>(NewDir) nmap <leader>nc <action>(NewClass) nmap <leader>nt :NERDTreeToggle nmap <leader>nf :NERDTreeFind
Â
You can directly use my IdeaVim configuration and adjust it to fit your own habits. Enjoy!
ideavim
sixdog06