This will allow you to switch between a Jetbrains IDE and gVim at the same file/line/column by hitting <leader>i. Hit <leader><leader>i to start gVim (once).
I've also done this with terminal Vim, but it's much more complex and varies depending on your environment (OS, DE, multiplexers, terminal).
Steps:
Install gVim and the IdeaVim plugin
In IDE: Settings > Build,Execution,Deployment > check "Allow unsigned requests"
Settings > Tools > External Tools > Alt+Insert
| Field | Value |
|---|---|
| Name | gvim-start |
| Program | gvim |
| Arguments | --servername $ProjectName$ |
| Working Directory | $ProjectFileDir$ |
Settings > Tools > External Tools > Alt+Insert
| Field | Value |
|---|---|
| Name | gvim |
| Program | gvim |
| Arguments | --servername $ProjectName$ --remote "+call cursor($LineNumber$, $ColumnNumber$)|call foreground()<CR>" "$FilePathRelativeToProjectRoot$" |
| Working Directory | $ProjectFileDir$ |
In ~/.vimrc:
nnoremap <leader>i :execute "silent !curl -fs 'http://localhost:63342/api/file/".expand("%")."?line=".line(".")."&column=".col(".")."'"\|redraw!<cr>In ~/.ideavimrc:
nnoremap <leader>i :action Tool_External Tools_gvim<cr>
nnoremap <leader><leader>i :action Tool_External Tools_gvim_start<cr>
I think I'll make this into a plugin. You'll have to add this to
~/.ideavimrcBut that might be too limiting. I may have to write a viml function, call like:
In the plugin the function
idea2vimwill do the following.ideagvim --servernameif not already runningcall cursor ... foreground)Also in the plugin will be another function
vim2idea:To make things even easier and to support updates, I might just say to add this to
.ideavimrc: