Escape to IntelliJ IDEA shortcuts from IdeaVim
Solution 1
I just turn VIM plugin off, execute keystroke, then turn it back on. I have ^Z bound to the VIM Emulator command for this purpose and it's enough for me. To set this up, go to Preferences... => Keymap, search for "vim emulator", and right-click on the command name to assign a shortcut.
But if you have a limited set of IntelliJ commands you want to use with a prefix key, you could pick the prefix key, make sure it is unbound in IntelliJ, and then use it in your ~/.ideavimrc
along with the original binding you wan to invoke.
For example, ^D in VIM is "Scroll window Downwards" and in IntelliJ (with keymap "Mac OS X 10.5+") is "Debug". If you want to be able to use both:
- choose a prefix key that's not bound in IntelliJ, say ^Z
- in Other Settings => Vim Emulation, find shortcut ^D and set the handler to Vim.
-
In your
~/.ideavimrc
, add the following mapping:nnoremap <C-Z><C-D> :action Debug<CR>
Now you can type ^D for the Vim action scroll down, or ^Z^D for the IntelliJ action Debug, without actually disabling IdeaVIM. You'll of course have to add a mapping to your ~/.ideavimrc for each IntelliJ command you want to execute this way, but if you have a limited number you can set them up once and be done with it.
Solution 2
I made .ideavimrc that contains bindings for all conflicted mappings. Maybe it'll be usefull to someone.
imap jj <Esc>
let mapleader = " "
map <leader>a :action $SelectAll<CR>
map <leader>b :action GotoDeclaration<CR>
map <leader>c :action $Copy<CR>
map <leader>d :action EditorDuplicate<CR>
map <leader>e :action RecentFiles<CR>
map <leader>f :action Find<CR>
map <leader>g :action GotoLine<CR>
map <leader>h :action TypeHierarchy<CR>
map <leader>i :action ImplementMethods<CR>
map <leader>m :action EditorScrollToCenter<CR>
map <leader>n :action FileChooser.NewFolder<CR>
map <leader>o :action OverrideMethods<CR>
map <leader>p :action ParameterInfo<CR>
map <leader>q :action QuickJavaDoc<CR>
map <leader>r :action Replace<CR>
map <leader>s :action SaveAll<CR>
map <leader>t :action Vcs.UpdateProject<CR>
map <leader>u :action GotoSuperMethod<CR>
map <leader>v :action $Paste<CR>
map <leader>w :action EditorSelectWord<CR>
map <leader>x :action $Cut<CR>
map <leader>y :action EditorDeleteLine<CR>
map <leader>[ :action EditorCodeBlockStart<CR>
map <leader>] :action EditorCodeBlockEnd<CR>
Solution 3
Adding onto the excellent answer by @melihovv, I have added the Run, Debug, and Choose Configuration actions to my ~/.ideavimrc
.
map <leader>dd :action Debug<CR>
map <leader>cd :action ChooseDebugConfiguration<CR>
map <leader>rr :action Run<CR>
map <leader>cr :action ChooseRunConfiguration<CR>
Solution 4
A keymap without any bindings here: to be used, so one could start from clean slate configuring the .ideavimrc
Thirteenth Seeker
Updated on July 05, 2022Comments
-
Thirteenth Seeker almost 2 years
I'm used to both vim and IntelliJ default hotkeys. I'd like to not to have to change any of them - I'd rather like to be able to use conflicting IntelliJ bindings, like CTRL-P for example, after some kind of escape key.
Conflict balloon and my research wasn't too helpful. Only thing that I've found is that I can turn vim plugin off with a hotkey, and then back on after I'm done, but I have to remember to turn it one every time.
Is there any solution for my problem?
-
Thirteenth Seeker over 8 yearsThat's a start of an interesting idea. I guess it's possible to parse IntelliJ and IdeaVim keymap files, and then make
.ideavimrc
that contains bindings for all conflicted mappings. I could do that and fit in in your answer and then accept it; I've just yet to find respective files (I've only found custom IDEA keymap .xml file and no default so far). -
AME over 7 yearsCool <3 Cool <3 Cool <3
-
x1a0 over 7 yearsSaved my day - now I have a bunch of stuff to add there :)
-
sunhang about 7 yearsI have try it, but MethodHierarchy.OverrideMethodAction not work.
-
melihovv about 7 yearsI updated answer. You can use :actionlist command to see all intellij actions to customize these mappings.
-
Hope almost 7 yearsOn my system (Win7 x64, PyCharm 2017.1.3) I needed to replace
map
withnnoremap
in order to get this work. Great idea though, thanks a lot! -
Hope almost 7 yearsFor some reason, I don't manage to get
<leader>r
open the replace window in visual mode, even if usingnoremap
orvnoremap
in this mapping. -
Justin Thomas almost 7 yearsCan you do <leader>pf ?
-
Ted over 6 yearswhat is "leader"?
-
Onewildgamer almost 6 yearsHow did you configure vimemulator with ^Z? I'm not able to do it.
-
old-monk over 5 years@Ted leader key is whatever you define, if you read carefully there's is line saying
let mapleader = " "
which make <space> a leader key, for example<space>+b
translates to:goto declaration
-
ARX about 5 yearsTo have IdeaVim read your changes to .ideavimrc, use
:source ~/.ideavimrc
-
Code Wiget over 4 years@Onewildgamer I second this. "I just turn VIM plugin off, execute keystroke, then turn it back on. I have ^Z bound to the VIM Emulator command for this purpose and it's enough for me." -- how do you do this?
-
jbyler over 4 years@Ryan, I just edited the answer to add instructions.
-
Dimon about 4 yearsTo find all actions, type
:actionlist
. Here is what i did to bind VCS/Commit action: 1) In IdeaVim / Settings set Ctrl+K "Commit..." to IDE handler; 2) list all actions with:actionlist
command; 3) found C-K there and copied action name - CheckinProject; 4) In IdeaVim / Settings set Ctrl+K "Commit..." to Vim handler; 5) add map in~/.ideavimrc
-nnoremap <C-z><C-k>:action CheckinProject<CR>
; 6):source ~/.ideavimrc
.