Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easier way to copy the path to a file or directory to the clipboard in visual studio?

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.

like image 708
leeand00 Avatar asked Apr 14 '11 19:04

leeand00


1 Answers

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.

like image 176
maru Avatar answered Oct 28 '22 06:10

maru