visual-studio 更改 Visual Studio 中的默认源文件目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3489127/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:21:21  来源:igfitidea点击:

Changing the default Source File Directory in Visual Studio

visual-studio

提问by Samaursa

This is not a work-stopper in any way, but I thought I should ask anyway because it is a littleannoying. Let's say I create a new project and start putting source files in a directory other than the default that shows up the first time. Afterwords, whenever I open the project, I have to navigate to the source directory once during that session. Like I said, not a big deal (but if solvable, then it's icing on the cake). Quite a few times I absentmindedly put the source file in the default directory and end up committing that file to the SVN and if I am lucky, going through all the files, removing them, then adding them again.

这不是一个工作,塞以任何方式,但我想我应该问反正,因为它是一个有点讨厌。假设我创建了一个新项目并开始将源文件放在第一次显示的默认目录以外的目录中。后记,每当我打开项目时,我都必须在该会话期间导航到源目录一次。就像我说的,没什么大不了的(但如果可以解决,那就是锦上添花)。有好几次我心不在焉地将源文件放在默认目录中,最终将该文件提交到 SVN,如果幸运的话,我会检查所有文件,删除它们,然后再次添加它们。

So my question is, is there any way to specify the default source directory on a per project basis?

所以我的问题是,有没有办法在每个项目的基础上指定默认的源目录?

回答by joshuanapoli

I have run into the same nuisance. I like to put the public interface header files for a library in a separate directory, but end up with file directory typos because I forget to navigate to the correct directory when saving a new file. Unfortunately, Visual Studio does not offer a setting to change the default directory for new C++ source files.

我遇到了同样的麻烦。我喜欢将库的公共接口头文件放在单独的目录中,但最终会出现文件目录拼写错误,因为我在保存新文件时忘记导航到正确的目录。遗憾的是,Visual Studio 不提供更改新 C++ 源文件默认目录的设置。

回答by Adelost

I had the same problem when I started using build systems (CMake, Premake) which requires me to keep my project files separate from my source files, which hampered my workflow.

当我开始使用构建系统(CMake、Premake)时,我遇到了同样的问题,这要求我将项目文件与源文件分开,这阻碍了我的工作流程。

Although changing the default source directory seems impossible, if you aren't afraid to spend money, the workaround I found was to use the Visual Assistextension.

尽管更改默认源目录似乎不可能,但如果您不怕花钱,我发现的解决方法是使用Visual Assist扩展。

  • You can bind a shortcut of your choise to the Create Filecommand which creates a new file relative to the directory or your open file.
  • I'd also recommend to base one's workflow around the wonderful Create from Usagecommand (which I think greatly boosts productivity) which almost eliminates the need to manually create files.
  • 您可以将您选择的快捷方式绑定到创建文件命令,该命令创建一个相对于目录或打开文件的新文件。
  • 我还建议将工作流程基于美妙的 Create from Usage命令(我认为这极大地提高了生产力),这几乎消除了手动创建文件的需要。

The extension is great, albeit a bit costly. I would love to see Microsoft incorporate these features directly in the IDE eventually as they are found vanilla in a lot of other IDEs e.g. Eclipse, Intellij.

扩展很棒,虽然有点贵。我很乐意看到 Microsoft 最终将这些功能直接合并到 IDE 中,因为它们在许多其他 IDE 中很常见,例如 Eclipse、Intellij。

There might be some free extensions available that does the same thing, but I haven't found any.

可能有一些免费的扩展可以做同样的事情,但我没有找到。

回答by Micah

Changing the Default Project Folder may help. This pagedemonstrates how to change the default for Visual Studio 2005, and it should be the same for later versions.

更改默认项目文件夹可能会有所帮助。此页面演示了如何更改 Visual Studio 2005 的默认值,并且对于更高版本应该是相同的。