views:

65

answers:

4

I set up a bunch of filters in my project to help find files. But all my source code files actually just go in two folders, source/headers... the filters are just for Visual Studio organization but I wanted to keep the directory structure simple for building in other compilers.

Anyway, whenever I add a new item or class, the files go in my /scripts folder and I have to move them. Is there a project-specific way to change this, I'm sick of having to do it!?

A: 

There is no such option that would do everything automatically for you. However, when adding a new item, you can right-click on the desired filter, choose Add -> New Item. In the dialog that opens you can change the path where the file will be created. After confirming the dialog, you will have the file both in the correct filter and in the correct folder.

dark_charlie
Yes that's what I do, _every_ file. It's a pain so I hoped I could map a filter to a directory or something.
John
A: 

It is not possible out of the box in visual studio 2005.

Things like this, the power of being independent from the project system and it's version change for each new release, opening the possibility to cross-platform building are all reasons I switched to CMake to generate programmatically the projects and solutions of my project. We harvest what we have on disk and all the filters in the projects are re-created based on what is on disk.

Haven't looked back.

Of course, this is another tool with a learning curve, but bringing a scripting engine to the build environment opens a whole lot of opportunities.

David
I don't fully 'get' what filters are for in VS. I think of them like folders but you can put file-type associations on them, it all seems a bit messy.
John
@John. You are right. The filter (or kind of folder, container) is assigned a series of extensions that it will allow to show in the container. I've never used it as such.
David
A: 

could you please clarify: do you have a scripts folder or scripts filter? VS should place new files in the Header Files/Source Files filter by default, does this happen?

You might be able to automate moving your files using Macros:

DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem("{original filename including filter}").Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("Edit.Cut")
DTE.ActiveWindow.Object.GetItem({target filter}).Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("Edit.Paste")

Code like this could be executed whenever files are added: How to: Handle Events by Using Macros

Philipp
+1  A: 

When you right-click on a filter and choose Properties, a window opens on the right of the screens. You will have a field named Filter, which contains the extensions supported by the current filter (example for include : h;hpp;hxx;hm;inl;inc)

Maybe your Scripts filter has a problem on this side.

Calvin1602
@John : Just for my information, did it work ? I never actually used this.
Calvin1602