Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 C++ Directive alignment

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
Millianz Posted - Jun 17 2011 : 9:11:06 PM
Hello,

This has been bugging me for a while and I'm not really sure whether this is Visual Studio or Visual Assist X behavior.

Basically every time you attempt to align #define or any other c++ directives using indentation with tabs or spaces, something moves the directive back to the beginning of the line.

I like to have defines the following way


#ifdef _MSC_VER
# define Break() __debugbreak()
#else
# define Break() do { __asm int 3 } while(0)
#endif


which is hard since VAX isn't keeping track of my current indentation.
6   L A T E S T    R E P L I E S    (Newest First)
Millianz Posted - Jun 22 2011 : 5:59:27 PM
I figured that it would be something visual studio does, too bad :(

That tool actually looks pretty cool, I'll give it a test run as soon as I have time for playing around with it :P

Thanks for the help guys.
feline Posted - Jun 21 2011 : 10:03:04 AM
You might want to look into a tool specifically designed to do code formatting / indenting. One commercial program is: http://www.profactor.co.uk/stylemanager.php

Personally I have never used this tool, but it sounds promising from the website description.
accord Posted - Jun 20 2011 : 7:17:26 PM
*ah* Now I see what you mean
This is definitely a Visual Studio behavior, it happens even when I disable VA via the extension manager:

Tools -> Extension Manager...

I took a quick glance at the text editor options in Visual Studio's option dialog but no luck. It doesn't mean you cannot turn it off somehow, though.
Millianz Posted - Jun 18 2011 : 5:24:41 PM
Hi,

Thanks for the answer, the namespace snippet works nicely.

Regarding the directive alignment, let me rephrase that a little bit.
The problem I'm having with directives is that they are auto formatted to always be at the beginning of the line.

Consider the following:

If I type something like

#if _DEBUG

and then hit enter and then tab (to indent):

#if _DEBUG
  |

and then type the pound symbol to write a second directive

#if _DEBUG
#....

something moves the entire line to the very beginning. I'm not sure if it's visual studio or visual assist x, but it becomes annoying quickly in larger files, for example if an entire code section is guarded from being included in release (debug methods, additional checks, asserts,....). An example of this would be


namespace Foo
{
  namespace Bar
  {
    Release code
    .
    .
    .
    #if _DEBUG

      void DumpBlocksInUse(void)
      {
        #if MEMORY_STATISTICS // Every time I type a new directive it is moved to the beginning of the line (try it)
          ...
        #else
          ...
        #endif
      }

    #endif
  }
}


I definitely don't think this issue deserves high priority in any way, BUT it is really annoying if you are working with a lot of pre processor directives.

--Mill
accord Posted - Jun 17 2011 : 10:56:50 PM
First question,
I don't really understand your question. If I select the lines and press tab, they will move and stays there. If I copy-paste them somewhere else, Visual Assist asks Visual Studio to format the selection which makes them move to the begging of the line. This can be turned off:

VA Options -> Advanced -> Correction -> Format after paste

Second question,
Yes, a snippet can be used. Just create the following snippet with shortcut "namespace", "ns" or whatever you like and paste the following line to last editbox of the snippet editor:
namespace $givenname$
{

} // $givenname$

This way, when you type your shortcut (i.e. ns) and then press enter, you will be prompted to type the name, e.g. Foo, so you will get what you wanted. Hope this helps :)
Millianz Posted - Jun 17 2011 : 9:13:29 PM
Another unrelated feature that would be nice (and maybe could be accomplished using VA snippets) would be to automatically comment the closing curly braces of namespaces with the namespace name, i.e:


namespace Foo
{

} // namespace Foo

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000