Do you really know how good you can make IntelliJ using vim bindings and the IdeaVim plugin? It took me quite a long time before I understood what it actually was capable of.
I really enjoy NeoVim, but being mainly a Java developer it still cannot beat IntelliJ in my opinion. Although I do miss the fact that the terminal is a buffer in NeoVim.
At first, I was using IdeaVim only for vim motions, which is great by itself, but then I started to understand how to configure it to be even better.
.ideavimrc
You might already know that IdeaVim reads its configurations from ~/.ideavimrc
.
Adding IDE actions here can be done as follows:
" Variant 1
nmap <Leader>rn <action>(RenameElement)
" Variant 2
nmap <leader>rn :action RenameElement<CR>
To reload the configuration, you can run the following vim command:
:source ~/.ideavimrc
The basic way to search for actions is done from the IDE itself.
" List all found actions
:actionlist
" Filter the action list
:actionlist git
Alternatively you can browse for actions. Here's a link to a collection of IntelliJ actions.
Also, adding plugins to your IDE adds new actions, that you can then map in you .ideavimrc
. They can
then be found with the :actionlist
command.
.ideavimrc
There are some pain points, but for the most part I can do everything that I need for my daily development without touching the mouse.
I hope this is either enlightening or inspiring.
" Load my default .vimrc
source ~/.vimrc
" IdeaVim specific command, which enables the mode widget on the lower right corner (this might not be necessary anymore)
set showmodewidget
" Run actions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Run the current class or test under the cursor
map <Leader>tr <action>(ContextRun)
" Run all tests in a class or the current class
map <Leader>trs gg<action>(RunClass)<C-O>
" Rerun previous job
map <Leader>tre <action>(Run)
" Open the run configuration dialog
map <Leader>rc <action>(ChooseRunConfiguration)
" Stop currently running process(es)
map <Leader>h <action>(Stop)
" Debug
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Debug the current class or test under the cursor
map <Leader>dr <action>(ContextDebug)
" Debug previous job
map <Leader>dre <action>(Debug)
" Add or remove breakpoint
map <Leader>da <action>(ToggleLineBreakpoint)
" Clear every breakpoint in the project
map <Leader>dsa <action>(Debugger.RemoveAllBreakpoints)
" Continue running from a breakpoint
map <Leader>i <action>(Resume)
" Open breakpoint dialog (add conditionals etc.)
map <Leader>de <action>(EditBreakpoint)
" Enable or disable breakpoint without removing it
map <Leader>dt <action>(ToggleBreakpointEnabled)
" Open ee dialog to run code at a breakpoint
map <Leader>ee <action>(EvaluateExpression)
" Continue running until cursor
map <Leader>rr <action>(RunToCursor)
" Global find and replace
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" These just open the default global search/search and replace
map <Leader>ff <action>(FindInPath)
map <Leader>fr <action>(ReplaceInPath)
" Harpoon (https://plugins.jetbrains.com/plugin/20782-harpoonij)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <C-t> :action GotoHarpoon1<cr>
nmap <C-h> :action GotoHarpoon2<cr>
nmap <C-n> :action GotoHarpoon3<cr>
nmap <C-s> :action GotoHarpoon4<cr>
nmap <C-e> :action ShowHarpoon<cr>
nmap <Leader>a :action AddToHarpoon<cr>
" Folds
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Collapse or expand everything by one
map <Leader>zc <action>(CollapseAllRegions)
map <Leader>zo <action>(ExpandAllRegions)
" Other
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>cc <action>(copilot.chat.show)
map <Leader>rn <action>(RenameElement)
" Format current file
map <Leader>fa <action>(ReformatCode)
" Open file encoding dialog
map <Leader>fe <action>(ChangeFileEncodingAction)
" Shows hover info for cursor position, good for checking errors or warnings
map <Leader>q <action>(ShowHoverInfo)
" Show info about the object under cursor
map <Leader>K <action>(GitContextMenu)
" Comments
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>cb <action>(CommentByBlockComment)
map <Leader>cl <action>(CommentByLineComment)
" Fuzzier (https://plugins.jetbrains.com/plugin/23451-fuzzier)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>sf <action>(com.mituuz.fuzzier.Fuzzier)
map <Leader>mf <action>(com.mituuz.fuzzier.FuzzyMover)
map <Leader>sg <action>(com.mituuz.fuzzier.FuzzierVCS)
" Reverts selected lines
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>grl <action>(Vcs.RollbackChangedLines)
" Windows
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>ter <action>(ActivateTerminalToolWindow)
" Open recent projects dialog
map <Leader>pr <action>(RecentProjectListGroup)
" Extras
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>gi <action>(GotoImplementation)