在 Visual Studio 中将文件或目录的路径复制到剪贴板的更简单方法?
为了实现此目的,我右键单击该文件或目录,然后选择“在 Windows 资源管理器中显示”,然后将路径复制到地址栏中。
是否有插件或宏可以使这项任务变得更容易?
我知道您可以将文件从解决方案资源管理器拖到编辑器中,它会写出路径,但是在进行 Web 开发时,我并不总是需要服务器路径,有时我需要本地路径。
To accomplish this I've been right-clicking the file or directory and then selecting Show in Windows Explorer, and then copying the path out of the address bar.
Is there an add-on or macro that can make this task easier?
I'm aware that you can drag a file from Solution Explorer into the editor and it will write out the path, but when doing web development I don't always want the server path, sometimes I want the local path.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
查看 PowerCommands 扩展
http://visualstudiogallery.msdn.microsoft .com/e5f41ad9-4edc-4912-bca3-91147db95b99?SRC=Home
其中,它包含文件和文件夹的“复制路径”命令
UPD:此外,另一个选项:右-单击打开文档的选项卡,将出现“复制完整路径”命令。它是内置的,无需扩展
Look at PowerCommands extension
http://visualstudiogallery.msdn.microsoft.com/e5f41ad9-4edc-4912-bca3-91147db95b99?SRC=Home
Among others, it contains "Copy Path" command for files and folders
UPD: Also, another option: right-click the tab of open document and there will be "Copy Full Path" command. It's built-in, no extensions needed
您只需在“解决方案资源管理器”文件列表中选择文件,然后按CTRL+C即可。它会自动将文件路径复制到剪贴板。
You can just select the file in the 'Solution Explorer' file list and hit CTRL+C. It automatically copies the file path to your clipboard.
我找到了如何在没有插件的情况下解决它的另一种选择(适用于 VS 2015 及更高版本;不确定以前的版本)
转到“工具”-> “定制...”-> “命令”选项卡。
选择“上下文菜单:”和“项目和解决方案上下文菜单|项”,您可以添加任何现有命令。
为了复制路径,选择类别“文件”和“复制完整路径”命令。仅为解决方案资源管理器中的文件添加按钮。
这也适用于项目,但您应该选择“项目和解决方案上下文菜单 | 项目”(.vcxproj 文件的复制路径)。
它不适用于解决方案,我实际上不明白为什么。
I've found one more option of how to solve it without plugins (for VS 2015 and above; not certain about previous versions)
Go to "Tools" -> "Customize..." -> "Commands" tab.
Choose "Context menu:" and "Project and Solution Context Menus | Item" and you can add any existing Command.
In order to copy path, choose Category "File" and "Copy Full Path" command. Will add button only for files in Solution Explorer.
This works for projects as well but you should choose "Project and Solution Context Menus | Project" (copy path of .vcxproj file).
It doesn't work for solutions and I don't understand actually why.
工具>选项>环境>键盘
您可以为任何内容设置自己的快捷键。与本文最相关的两个是“File.CopyFullPath”和“File.CopyRelativePath”。
我创建了仅在“文本编辑器”中使用的快捷方式,并且效果很好。
这是针对 VS2010 的要求,而我正在使用 VS2019,所以这是一个老问题,但仍然相关。我知道文件头右键单击菜单,但由于某种原因,我没有想到快捷键,直到我读到这个问题。发布此信息以防其他人更快地修复。
Tools > Options > Environment > Keyboard
You can set your own shortcut keys for anything. The two that are most relevant to this post are "File.CopyFullPath" and "File.CopyRelativePath".
I created my shortcut to just be used in "Text Editor" and it has worked great.
This was asked for VS2010 and I'm using VS2019, so it is an old question, but still relevant. I knew about the file header right click menu, but for some reason I didn't think about the shortcut keys until I read this question. Posting in case this results in a quicker fix for anyone else.
CTRL+C 在 MSVS 2017 上对我不起作用。
在此处使用副本作为路径扩展。
然后在解决方案资源管理器中右键单击文件 ->复制为路径(或指定快捷方式)。
我发现它效果很好。
The CTRL+C doesn't work for me on MSVS 2017.
Use the copy as path extension here.
Then right click on file in solution explorer -> Copy as path (or assign a shortcut).
I find that it works very well.