Jas
Jas

Reputation: 15123

ideavim how to navigate to declaration / implementation of a method?

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.

Upvotes: 41

Views: 27508

Answers (5)

davidj411
davidj411

Reputation: 1015

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...

Upvotes: 0

Matt Klein
Matt Klein

Reputation: 8444

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"

Upvotes: 6

DuckOfDoom
DuckOfDoom

Reputation: 13

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.

Upvotes: 0

sudoz
sudoz

Reputation: 3553

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.

Upvotes: 40

Henry Crutcher
Henry Crutcher

Reputation: 2297

I've noticed that 'gd' seems to go to the declaration.

Upvotes: 113

Related Questions