visual-assistvisual-assist-x

Trim File Name in Visual Assist Snippet/Macro


I am using Visual Assist X in Visual Studio 2008. I am defining a bunch of forward declaration files, all of which have basically the same format:

namespace ns1 { namespace ns2 {
    class SampleClassName;
    boost::shared_ptr<SampleClassName> SampleClassNamePtr;
}}

Obviously, I'm also putting in a header guard, a generated file comment, and other things as required by our coding standard (and the namespaces aren't placeholders).

Here's the issue: we name these files SampleClassNameForward.h so using the $FILE_BASE$ placeholder won't exactly work. Is there a way for me to apply a regex and remove the "Forward" from $FILE_BASE$ after it has been expanded, but prior to the snippet being pasted into my file? If I could do that, then I could fully automate generating these forward declarations and save myself (and my colleagues) a ton of time.


Solution

  • No, Visual Assist does not have any tools that would support regex modification of the file name as you are looking to do.

    An alternative approach would be to create a VA Snippet that you use to create the block of code in a temporary file.

    Move Selection To New File will create the new file in the same directory as the current file and add it to the same projects it is in.