Author Topic: Editor idea: F11 swap directly between method definition (.h) and body (.cpp)  (Read 4206 times)

Offline MB

  • Multiple posting newcomer
  • *
  • Posts: 12
Just an idea for the editor that would be very useful:

If the cursor is inside a method body (.cpp file):

void X:foo()
{
  ... <=
}

then pressing F11 jumps to the .h file and (new feature) places the cursor on the method definition line:

class X
{
  void x();
  void foo(); <=
  void z();
};

And pressing F11 in the .h file (with the cursor on a method definition line) => jumps to the .cpp file with (new feature) the cursor inside the body of the method.

This makes navigating back and forth between method definition and method body very fast.
« Last Edit: July 11, 2006, 04:09:49 pm by MB »

Offline kidmosey

  • Multiple posting newcomer
  • *
  • Posts: 95
    • MUSITU International
First of all, why do you need to go to the method declaration?  All that will do is tell you what you already know.  Personally, I keep the header scrolled to the internal variables.  If the IDE was constantly changing my cursor location, I would quickly get frustrated.

Doing something like this limits the usage of F11.  Generally, it is not too difficult to scroll a header file to the correct method declaration, and in most cases you are interested in looking at various other methods instead of the one you are currently in.

And then would you make it visa versa, as well?  That way would be even more frustrating, you move the cursor in the header file and you are suddenly somewhere else in your code, miles away from what you were working on.

Maybe if document switching gets changed so it goes to the previous document instead of round-robin, it might work (in which case I wouldn't use f11 anymore), but even then it should only be an option in the preferences.
3 years until google knows more than god.

Offline fili

  • Multiple posting newcomer
  • *
  • Posts: 15
  • Meow
I think that this kind of jumping would be useful. Some IDE's have ctrl+click (or ctrl+b) on the function/variable to jump to it's declaration. Or, even more useful, jump from function use to function declaration or implementation. Anything that eases navigation is good. My favourite Java IDE (IntelliJ Idea) has multiple jumping possibilities. So, why not C::B?

LE: you need to go to a function declaration for modifying it's parameters, for example. Let's say I have the foo(int) function. I want to create the foo(int,int) function and declare it next to the foo(int). Or something else...
« Last Edit: July 12, 2006, 07:39:55 am by fili »
Have FUN,
FeeL E!

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
You could use right click on the method/function name -> "Find declaration/implementation of" to jump from one place to another and even use Shift+F12 (Toggle all folds) in source files to get, basically, the name of all methods.

I'm also wondering why you would like something like that. I find it useful only to compare function/method signatures, but that's something you'ren't constantly doing.

kidmosey: nice and disturbing avatar you got there :P

Offline kidmosey

  • Multiple posting newcomer
  • *
  • Posts: 95
    • MUSITU International
kidmosey: nice and disturbing avatar you got there :P

haha, yeah... my wife, the photographer.
3 years until google knows more than god.

Offline Charon

  • Multiple posting newcomer
  • *
  • Posts: 49
  • fnord
    • charon - where mental illness meets chronic nonsense
not directly connected with this, but i think it fits in this topic :
i think it would be pretty helpful to have a drop-down box in a toolbar at the top that shows every function in the actual file. when you select a function through this drop-down your cursor gets placed at the start of it. (if you manually place your cursor in a function the drop-down should change accordingly, in larger files its easy to see in which function you are this way)

although shift+f12 folds everything and shows me every function in a file this way, its not really a help. imagine you already folded some if-statements, pressing shift+f12 two times (fold and unfold again) destroys al your manual placed folds.

mh, i hope this makes sense :-D


kidmosey : is this a paintball mask from brass eagle?
hi, i am a signature virus. please copy me into your sig!
Wish list : no root-node for workspaces, open files and symbols; world domination

Offline kidmosey

  • Multiple posting newcomer
  • *
  • Posts: 95
    • MUSITU International
i think it would be pretty helpful to have a drop-down box in a toolbar at the top that shows every function in the actual file. when you select a function through this drop-down your cursor gets placed at the start of it. (if you manually place your cursor in a function the drop-down should change accordingly, in larger files its easy to see in which function you are this way)

This seems like a good feature, but I wonder if it would be redundant in addition to the "Symbols" tab in the workspace panel (switch to flat mode).

kidmosey : is this a paintball mask from brass eagle?

No, she had to kill like 80 people and become a convicted "hannibal" so she could maintain realism.
3 years until google knows more than god.

Offline MB

  • Multiple posting newcomer
  • *
  • Posts: 12
First of all, why do you need to go to the method declaration?  All that will do is tell you what you already know.  Personally, I keep the header scrolled to the internal variables.  If the IDE was constantly changing my cursor location, I would quickly get frustrated.

Doing something like this limits the usage of F11.  Generally, it is not too difficult to scroll a header file to the correct method declaration, and in most cases you are interested in looking at various other methods instead of the one you are currently in.

And then would you make it visa versa, as well?  That way would be even more frustrating, you move the cursor in the header file and you are suddenly somewhere else in your code, miles away from what you were working on.

Maybe if document switching gets changed so it goes to the previous document instead of round-robin, it might work (in which case I wouldn't use f11 anymore), but even then it should only be an option in the preferences.


I find the feature to be very useful and (as the posts shows) others do as well. So it should probably be an option to have it enabled or not. In the same way that other options can be switched on/off because people have different preferences.