Jump to next above/below class declaration?

651 views Asked by At

Alt + Down or Alt + Up will jump to next/previous method relative to your current cursor position. Is there a similar functionality for jumping to the next above/below class?

2

There are 2 answers

0
bad_coder On BEST ANSWER

The default keymap doesn't give the exact functionality you want. Cycling previous/next classes, like you cycle the methods, isn't possible. The closest thing is opening a list using Ctrl+F12 with all the members in the module.

  • Go to Settings Ctrl+Alt+S and select Keymap.

    • In Keymap -> Main Menu -> Navigate there's Ctrl+F12 that gives the list of objects in the file.

    • In Keymap -> Main Menu -> Navigate -> Navigate in File are the Alt+Up and Alt+Down shortcuts to cycle next/previous methods as you mentioned in the question.

0
maxizmail11 On

I solved this via IdeaVim plugin by adding this to .ideavimrc file (we use its search here):

nnoremap gU ?class <CR>
nnoremap [[ ?class <CR>
nnoremap ]] /class <CR>

gU takes you to the current class declaration. [[, ]] for previous/next.