The "open file" dialog in Visual Studio Code is not showing hidden files. For example, when looking at my home directory, none of the . files are shown:
I did look through the settings.json file, but I did not find any applicable setting. So - how do I configure Visual Studio Code properly?
On Mac you can hit cmdshift. in the open file dialog, to see hidden files.
(Source)
go to file -> preferences -> settings
and in the search bar, search for "files.exclude"
then delete whatever json setting that you don't want to hide that specific file
Under Linux you can right click on files in the file selection window and check the "Show Hidden Files" checkbox.
Here's a screenshot from Ubuntu 20.04.1 LTS, VS Code v 1.52.1 after right clicking on the header.php file with "Show Hidden Files" option enabled:
To display hidden .git directories in Visual Studio Code, do the following:
On Windows or Linux, select File → Preferences → Settings.
On Mac, select Code → Preferences → Settings.
In Visual Studio Code settings (Settings Editor), select Editor → File and scroll to (or search for) Exclude. Comment out the glob to exclude .git files (// **/.git). See the attached screenshot: VS Code glob commenting.
Also see Visual Studio Code User and Workspace Settings. You will find the default settings on the page, which you could edit, but I chose to comment the glob out to conveniently hide these files later should I so desire.
Visual Studio Code: Show hidden folders contains more information on the subject.
On Windows, in VS Code, go to File > Preferences > Settings.
Search file.exclude and hover over the hidden files you want to see and click the "X"
Linux:
ctrl + ","
in search, type: "files exclude"
This shows all the patterns VS Code uses when deciding what to ignore. If you wanted to view a .git folder, you would simply remove that pattern from the list of patterns "**/.git". When you want to stop seeing it, just add that pattern back.
On Windows, open the .vscode folder in the explorer and comment out the file types you wish to see. There is no need to restart VS Code, just click the refresh explorer button.
If anyone wants a quick way to toggle the visibility of hidden files, you can use an extension:
Peek Hidden Files:
Toggle the visibility of excluded files by Explorer's context menu. I'm currently using this one.
Make Hidden:
Has a context menu option to hide selected items in Explorer.
Has an area to view hidden files.
Explorer Exclude:
Can control hidden file glob patterns without going to settings.json.
preview image
In menu View in Visual Studio Code, select SCM (shortcut Ctrl + Shift + G), right click on the Git icon, click here and select Keep.
Related
I have uninstalled Visual Studio Code, but the "open with code" option is still in my context menu when I right click a folder.
If I install VS Code again, it will keep the old option and adds a second entry which opens VS code.
This link will help you to modify registry.
Most of the menu items that used for all files and folders can be found at one of these keys:
HKEY_CLASSES_ROOT\*\shell
HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers
HKEY_CLASSES_ROOT\AllFileSystemObjects\ShellEx
I used ShellMenuView to find the offending records (there were several) and optionally disable them. You can then right click and select properties on the "Open with code" rows to find the registry paths. With that info I could delete the relevant keys from the registry manually. One was HKEY_CLASSES_ROOT\directory\shell\Ticino\Command but there were others.
Old question, but I got here searching for those exact terms.
You may also find right click options here:
HKEY_CLASSES_ROOT\Directory\Background\shell
HKEY_CLASSES_ROOT\Directory\shell\
You can also move them to shift+right click as per this answer: https://superuser.com/a/1332589
Just installed update 1 of vs2013 and now I can't drag .js or .css files from the solution explorer into my html views anymore.
Before you could do this and vs automatically created a script tag or link tag to the file. I'm not sure if it has something to do with the update 1 but I really miss that now, is there a way to re-enable it?
I had this problem in VS 2015; resolved by (re-)enabling:
(Menubar) Tools -> Options -> Text Editor -> General -> "Drag and drop text editing"
This not only affects the ability to drag and drop highlighted text (which is why I had turned it off in the first place), but also the ability to produce an automatically formatted link by dragging and dropping a file onto the editor window. There may be a way to separate the two, but I have not come across it.
The same option is present, by the way, in the same location, in VS 2012. However, I did not test the behavior of the option in that version.
I had the same problem and this is how I fixed it...
Option 1:
Go to Tools > Options > Text Editor > File Extension
...and add the extension of the file you are editing. In the editor selection list choose HTML Editor if it is an html or quivalent code you are working on... or just select the kind of code you are writing. After that hit Ok, restart VS and it should work now...
Option 2:
Right click on the file and select open with HTML Editor, save as default, and that should work as well.
Cheers
Try running as administrator, if you are not already.
I had this same problem. I tried #VictorSuarez's solution of adding the edited file's extension to the list of files to opened by the HTML Editor, but it did not immediately solve the problem. I then opened Visual Studio as an admin and was able to drag and drop links as expected.
For vs2022 this should be fixed in: Visual Studio 2022 version 17.3 Preview 3. Accordingly with quote from "Fixed - Pending Release" developer community issue from Jul 13, 2022:
A fix for this issue is now available in preview release. Try out the
fix by installing the most recent preview from
https://visualstudio.microsoft.com/vs/preview/ .
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.
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
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.
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.
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.
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.
I have a file, xyz.cpp. I want to open two instances of this file in Visual studio (BTW, I am using Visual Studio 2005). Why would I want to do so? I want to compare two sections of the same file side by side. I know workarounds such as:
Make a copy of the file. But the problem is that it's not elegant, and I don't want to make copies every time I am faced with this.
I can split the window into two. The problem with split it that I can split it horizontally only. The result of a horizontal split is that the right half of my screen is white space.
If I were able to split it vertically or open two instances of the same file, it would increase the number of lines of code I can compare.
Visual Studio
Here's how to do it...
Select the tab you want two copies of
Select menu Window → New Window from the menu.
Right click the new tab and select New Vertical Tab Group
If New Window is not listed in the *Window menu note that the command does exist, even as of Visual Studio 2017. Add it to the Window menu using menu Tools → Customize → Commands. At that point decide where to put the New Window command and select Add Command.
VS Code
In Visual Studio Code version 1.25.1 and later
Way 1
You can simply left click on your file in the side-panel (explorer) and press Ctrl + Enter.
Way 2
Simply right click on your file in the Visual Studio Code side-panel (explorer) and select the first option open to the side.
For Visual Basic, HTML and JScript and RDL Expression, the Window > New Window option mentioned in PaulB's answer is disabled.
However an option can be changed in the Registry to enable the menu item.
All other languages do not restrict to a single code window so you can use PaulB's answer without editing the registry.
Enabling New Window in Windows Registry.[1] [2]
Go to the following registry key. This example is for Basic (Visual Basic), but the key is also there for HTML, JScript and RDL Expression.
64-bit OS: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Languages\Language Services\Basic
32-bit OS: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Languages\Language Services\Basic
Find the value Single Code Window Only and do one of the following:
Set it to 0
Rename the value
Delete the value (use caution!)
This will enable the "New Window" menu item, but it may still not be visible in the menu.
Adding Menu Item
To actually see the New Window menu item I had to add it back into the menu:
Tools > Customize... > Commands > Add Command...
Select 'Menu Bar' the select the 'Window' menu in the dropdown
Add Command... > Window > New Window > OK
Restoring Registry Value
Copy-paste this to notepad, save as a .reg file and import the file into your registry to restore the initial setting.
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Languages\Language Services\Basic]
"Single Code Window Only"=dword:00000001
Go to menu → Windows → New Window:
You can use the Windows → New Window option to duplicate the current window. See more at: Why I like Visual Studio 2010? Undock Windows
Open the file (if you are using multiple tab groups, make sure your file is selected).
Menu Window → Split
(alternately, there's this tiny nub just above the editor's vertical scroll bar - grab it and drag down)
This gives you two (horizontal) views of the same file. Beware that any edit-actions will reflect on both views.
Once you are done, grab the splitter and drag it up all the way (or menu Window → Remove Split).
How to open two instances of the same file side by side in Visual Studio 2019:
Open the file.
Click Window → New Window.
A new window should be open with the same file.
Click on Window → New Vertical Document Group.
Result:
With the your file opened, go to command window (menu View → Other Windows → Command window, or just Ctrl + Alt + A)
Type:
Window.NewWindow
And then
Window.NewVerticalTabGroup
worked for me (Visual Studio 2017).
Or using menus:
Menu Window → New Window
Menu Window → New vertical tap group
Luke's answer didn't work for me. The 'New Window' command was already listed in the customize settings, but not showing up in the .js tabs context menu, despite deleting the registry setting.
So I used:
Tools
Customize...
Keyboard...
Scroll down to select Window.NewWindow
And I pressed and assigned the shortcut keys, Ctrl + Shift + W.
That worked for me.
==== EDIT ====
Well, 'worked' was too strong. My keyboard shortcut does indeed open another tab on the same JavaScript file, but rather unhelpfully it does not render the contents; it is just an empty white window! You may have better luck.
Window menu, New Horizontal/Vertical Tab Group there will do, I think.
When working with Visual Studio 2013 and VB.NET I found that you can quite easily customize the menu and add the "New Window" command - there is no need to mess with the registry!
God only knows why Microsoft chose not to include the command for some languages...?
For newer versions (such as Visual Studio 2017)
Select the window you want to duplicate.
Go to the window tab and click on split at the top of the list.
When you are done, click it again to toggle it off.
For file types, where the same file can't be opened in a vertical tab group (for example .vb files) you can
Open 2 different instances of Visual Studio
Open the same file in each instance
Resize the IDE windows & place them side by side to achieve your layout.
If you save to disk in one instance though, you'll have to reload the file when you switch to the other. Also if you make edits in both instances, you'll have to resolve on the second save. Visual Studio prompts you in both cases with various options. You'll simplify your life a bit if you edit in only the one instance.
I don't have a copy of Visual Studio 2005, but this process works on Visual Studio 2008:
Open xyz.cpp along with some other file.
Right click on tab header and select new vertical tab group.
Left click on that other file in the first tab group.
Open xyz.cpp through solution explorer again.
You should now have two instances of file in separate vertical tab groups.
To work on two sections of one long file, simply use a shortcut (Ctrl + \) or click on the split editor window while you are on the selected tab. The icon is on the top-right of the Visual Studio Code.
In Visual Studio with TFS as source control, when I view the history and double click a cs file, the file is loaded in notepad. How can i change the application to be notepad++?
I also would like the OS's default application for the file to still be visual studio
After pouring over ProcessMonitor logs I think I found the solution!
You need to change the what the Windows shell (explorer) thinks the "Edit" action for text files. I was able to change this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\text\shell\edit\command
to something other than Notepad (in my case notepad2). Now Visual Studio's TFS's changeset dialog opens cs files with that editor.
This will probably change the edit option for not just cs files, but everything considered "text'. The registry entries for file associations are pretty complicated. I suspect that it would be possible to disassociate .cs files from this common "text" category and make this change only for cs files (but I'm not that ambitious). Also, I wouldn't be surprised if people's file associations / shell commands (open, edit, etc...) vary from machine to machine (OS versions, tools installed, etc) - so YMMV.
The only way I found is to replace notepad with notepad++. This article describes how to do it. Don't forget to check the comments to get a link to the "little exe" that comes with notepad++.
Works like a charm on W7 x64.
Cheers,
Phil
\I was able to configure this by adding new value to the registry.
OS: Windows 7 Enterprise x64
Steps on how to do it.
Run: Regedit (alt + r, type regedit)
Look for HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations
Right click "SystemFileAssociation" -> add new key then name it as .cs
Right click .cs and add new key then name it as shell
Right click shell and add new keys name it as edit and open 6
Right click edit and add new key command then change the default value to point to the file exe you want it to run.
ex: C:\Program Files (x86)\Notepad++\notepad++.exe %1
Don't forget to add the %1 at the end of the .exe
do the same for open
Hope it helps.
I don't see any options in Visual Studio for changing that, so I'm guessing it uses the system's default text editor.
Try assigning Notepad++ as the default handler for *.cs files.
You can do this from withing Notepad++ by going to Settings/Preference/File Association.
You can also do it by right-clicking on a .cs file in explorer, go to Open With/Choose Program..., then select Notepad++ and check the "Always use the selected program to open this kind of file" box before hitting OK.
The only thing that works for me is when I set the default program for the particular file type in Windows Explorer to open with the VS IDE:
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
This opens the code in a new instance of VS. Not ideal, but at least it's easier to read.