I was reading: http://ideavim.sourceforge.net/vim/quickref.html .
When my cursor is on a method how do I navigate to its declaration / impelementation (like ctrl-b in normal mode) I tried gd
but it did not do anything.
![](../../users/profiles/345859.webp)
- 12,534
- 20
- 79
- 134
-
4The closest I found was: go to Settings/Vim Emulation, find Ctrl+B shortcut, change Handler from Vim to IDE and Ctrl-B will work as expected. – seeg Nov 19 '14 at 14:58
5 Answers
I've noticed that 'gd' seems to go to the declaration.
![](../../users/profiles/2532708.webp)
- 1,919
- 17
- 25
-
5You can also use Ctrl + o to go back th where you came from after using 'gd' – Nagarjun Prasad Jan 08 '20 at 06:59
-
@NagarjunPrasad Ctrl + o works for me. How do I redefine this short-cut with another key combination? Thank you – Zack Xu Feb 13 '21 at 00:24
With ideavim default settings, press 'gd' in Normal mode can jump to the declaration, but no way to go to the implemetation by default.
So you can modify it by yourself, touch new file ~/.ideavimrc
, and then set your own keymapper in that file:
nmap g] :action GotoImplementation<CR>
'GotoImplementation' is an action defined by IntelliJ,so press 'g]' will run this action. Try it.
![](../../users/profiles/4305743.webp)
- 2,241
- 1
- 17
- 16
-
2This was a really good suggestion. I just tweaked it a little bit to make it easier for my muscle memory. To do that, I use 'gD' instead of 'g]'. As a last note, @Jas , I believe you should mark this as the right answer. It is complete and it solves your problem. – Alexandre Martins Dec 07 '16 at 12:39
-
-
In my case, I want Ctrl-B
to do the default "Go To Declaration", but it wouldn't do anything because Vim emulation was intercepting the key combo.
The fix for me was
Preferences
> Editor
> Vim Emulation
> "Ctrl-B, Declaration"
> Change from "Vim" to "IDE"
![](../../users/profiles/1672027.webp)
- 6,282
- 4
- 37
- 42
I find it hard to remember that some combination that normally works in vim doesn't work b/c it conflicts with the IDE.
it gets more difficult to keep it straight in my mind if I start making exceptions within the "vim emulator".
"CTRL + b" works great in the IDE to "goto definition". why press "vim emulator" to do the same thing?
instead of having to keep complicated things in my mind, i found it easier to add a keyboard shortcut (ALT + 9) to toggle the "vim emulator" on/off quickly ("tools" --> "vim emulator").
Edit in VIM mode.
Want to trace back to see where something is defined? flip the toggle.
"CTRL + b" away!
toggle back to VIM mode to edit more...
![](../../users/profiles/1281361.webp)
- 707
- 7
- 9
You can map "GotoImplementation" method to go to implementation. To return to base method, you can use "GotoSuperMethod
" action instead.
And yes, it works even in Rider, even when there are no "super"-classes in .net.
![](../../users/profiles/2227834.webp)
- 15,690
- 193
- 65
- 96
![](../../users/profiles/3793144.webp)
- 13
- 2