In the Solution Explorer when working with C++ projects there is the standard filters of Header Files, Resource Files, and Source Files. What I'm wanting to accomplish is essentially Filters by folder.
在使用C ++项目时的解决方案资源管理器中,有标题文件,资源文件和源文件的标准过滤器。我想要完成的主要是按文件夹过滤。
Lets say the structure of the files was like this:
让我们说文件的结构是这样的:
- ../Folder1/Source1.cpp
- ../Folder1/Header1.h
- ../Folder1/Source2.cpp
- ../Folder1/Header2.h
- ../AnotherFolder/Source1.cpp
- ../AnotherFolder/Header1.h
- ../AnotherFolder/Source2.cpp
- ../AnotherFolder/Header2.h
- ../SomeOtherSource.cpp
In the Solution Explorer, it would look like:
在解决方案资源管理器中,它看起来像:
- Header Files/Header1.h
- Header Files/Header1.h
- Header Files/Header2.h
- Header Files/Header2.h
- Source Files/SomeOtherSource.cpp
- Source Files/Source1.cpp
- Source Files/Source1.cpp
- Source Files/Source2.cpp
- Source Files/Source2.cpp
And I would like to have it look like this:
我希望看起来像这样:
- Header Files/AnotherFolder/Header1.h
- Header Files/AnotherFolder/Header2.h
- Header Files/Folder1/Header1.h
- Header Files/Folder1/Header2.h
- Source Files/AnotherFolder/Source1.cpp
- Source Files/AnotherFolder/Source2.cpp
- Source Files/Folder1/Source1.cpp
- Source Files/Folder1/Source2.cpp
- Source Files/SomeOtherSource.cpp
How would this be accomplished?
这将如何实现?
4 个解决方案
#1
You are free to manually create folders yourself and move the files around. I agree this is a much more convenient way to arrange files but AFAIK there is no way to make VS do this automatically.
您可以自己手动创建文件夹并移动文件。我同意这是一种更方便的方式来安排文件,但AFAIK没有办法让VS自动执行此操作。
#2
You can create the Visual Studio Plugin to do this. I am not sure how you can access "Solution Explorer" programatically.
您可以创建Visual Studio插件来执行此操作。我不确定如何以编程方式访问“解决方案资源管理器”。
#3
show all files?
显示所有文件?
#4
The only method I have found for doing this is completely manual. I have created a hierarchy of filters to match the folders. Then, I move to the "Show All File" view, and select a single folder. I add all files from that folder that are not in my solution to the solution. Then I leave "Show All Files.
我发现这样做的唯一方法是完全手动的。我创建了一个过滤器层次结构来匹配文件夹。然后,我移动到“显示所有文件”视图,并选择一个文件夹。我将该文件夹中不在我的解决方案中的所有文件添加到解决方案中。然后我离开“显示所有文件”。
At this point, VS does not seem to properly update my list of files. So I need to "Close Solution" and re-open the solution. At this point, the new files are in the solution, but not in a filter. They are in the top level, at the bottom of the project. At which point I drag them into the correct filter.
此时,VS似乎没有正确更新我的文件列表。所以我需要“关闭解决方案”并重新打开解决方案。此时,新文件位于解决方案中,但不在过滤器中。它们位于项目底部的顶层。此时我将它们拖动到正确的过滤器中。
This is tedious, error-prone, and a waste of time. But since my project is built using an external make system, it's the only way I can keep the project reasonably up-to-date and still get decent search and browse behavior in Visual Studio. The time cost pays itself back in productivity later, but I still begrudge it.
这很乏味,容易出错,浪费时间。但由于我的项目是使用外部make系统构建的,因此这是我能够合理地保持项目最新状态并且在Visual Studio中仍能获得良好搜索和浏览行为的唯一方法。时间成本会在以后的生产力中恢复,但我仍然不喜欢它。
#1
You are free to manually create folders yourself and move the files around. I agree this is a much more convenient way to arrange files but AFAIK there is no way to make VS do this automatically.
您可以自己手动创建文件夹并移动文件。我同意这是一种更方便的方式来安排文件,但AFAIK没有办法让VS自动执行此操作。
#2
You can create the Visual Studio Plugin to do this. I am not sure how you can access "Solution Explorer" programatically.
您可以创建Visual Studio插件来执行此操作。我不确定如何以编程方式访问“解决方案资源管理器”。
#3
show all files?
显示所有文件?
#4
The only method I have found for doing this is completely manual. I have created a hierarchy of filters to match the folders. Then, I move to the "Show All File" view, and select a single folder. I add all files from that folder that are not in my solution to the solution. Then I leave "Show All Files.
我发现这样做的唯一方法是完全手动的。我创建了一个过滤器层次结构来匹配文件夹。然后,我移动到“显示所有文件”视图,并选择一个文件夹。我将该文件夹中不在我的解决方案中的所有文件添加到解决方案中。然后我离开“显示所有文件”。
At this point, VS does not seem to properly update my list of files. So I need to "Close Solution" and re-open the solution. At this point, the new files are in the solution, but not in a filter. They are in the top level, at the bottom of the project. At which point I drag them into the correct filter.
此时,VS似乎没有正确更新我的文件列表。所以我需要“关闭解决方案”并重新打开解决方案。此时,新文件位于解决方案中,但不在过滤器中。它们位于项目底部的顶层。此时我将它们拖动到正确的过滤器中。
This is tedious, error-prone, and a waste of time. But since my project is built using an external make system, it's the only way I can keep the project reasonably up-to-date and still get decent search and browse behavior in Visual Studio. The time cost pays itself back in productivity later, but I still begrudge it.
这很乏味,容易出错,浪费时间。但由于我的项目是使用外部make系统构建的,因此这是我能够合理地保持项目最新状态并且在Visual Studio中仍能获得良好搜索和浏览行为的唯一方法。时间成本会在以后的生产力中恢复,但我仍然不喜欢它。