質問

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.

役に立ちましたか?

解決

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

他のヒント

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.

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"

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.

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top