17

Is there any Visual Studio 2008 add-in or macros to sort method implementations in .cpp file according to the order of their declarations in .h file? EDIT: any recent Visual Studio (2010, 2013, 2015, 2017, 2019, 2022)

cos
  • 940
  • 1
  • 10
  • 25
  • unlikely. refactoring tools don't generally work with c++. What's the point anyway? – sehe Feb 13 '12 at 12:29
  • @sehe : There is Visual Studio plugin called Visual Assist X that allows you to refactor C++ code - it's not that great, but at least something. – LihO Feb 13 '12 at 12:34
  • 2
    The point is to do this automatically. I like when methods in cpp files are ordered in some way. And it's easier to reorder them in header file. – cos Feb 13 '12 at 12:35
  • 1
    @LihO: I already use Visual Assist X. And it seems that it doesn't provide such functionality (I can reorder method implementations in cpp using drag'n'drop in VA Outline tab, but that's not what I'm looking for) – cos Feb 13 '12 at 12:39
  • @cos : It was reaction to sehes *"refactoring tools don't generally work with c++"*. I know it is something that VA can't do. It is too specific and unusual. Also I don't understand why would you do that since most of IDEs support "Go to definition" or showing you methods body by choosing it from list. – LihO Feb 13 '12 at 12:43
  • 1
    +1 I usually do this manually as well. Makes the includes look nicer! Would be nice with tool support. – rasmus Feb 13 '12 at 13:22
  • I know this doesn't help with reordering existing code but in VS 2015, if you declare the method in the header but don't define it yet proofing tools will underline it. If you `Ctrl+.` there will be an option to auto-add the definition stub in the cpp file and it is added in the correct place to match the header. – CodingLumis Jun 29 '17 at 15:24

1 Answers1

3

Although not a tool as the submitter asked for.... i personally collapse all function bodies (CTRL+M+O) and then manually order them...

but again VA allows you to look for methods by alphabetic order in their drop down text editor control

NirMH
  • 4,769
  • 3
  • 44
  • 69