How can we add existing file to VS code solution, I am not getting 'Add existing item' option - visual-studio-code

Can we add existing file or folder to VS code solution from explorer itself ?
One way is to add from file explorer but can this be done from VS code explorer itself like other Visual studio IDE solution explorer ?

We can't add it like Visual Studio IDE as how you will always have a link to it.
However, you can "Open" a file temporarily via Cntrl+O or can open a new Window with that other folder opened.

On Linux, the existing file can be inserted by copying to system's clipboard then paste from VSC.
To copy to system's clipboard:
xclip <filename>
Then paste to VSC as usual using Ctrl-V.

Related

How do I open the 'launch.json' file in Visual Studio Code?

I am a new programmer that started learning Python, but there's something bothering me which I'd like to change.
As I've seen that it is possible to remove the unwanted path from the terminal when executing code, I cannot figure out how to access the Visual Studio Code launch.json file and all of the explanations on Google are quite confusing.
Note that if Visual Studio Code hasn't created a launch.json file for your project yet, do the following:
Click the Run | Add Configuration menu option, and one will automatically be generated for you, and opened in the editor.
NOTE: You have to have a "Folder" open, for this to work. File | Open Folder...
In Visual Studio Code, use shortcut Ctrl + Shift + P to open the Command Palette and type Open launch.json. And it will open the launch.json file for you. If you also can't open launch.json then try the way below.
Check if the .vscode folder exists in the root folder. If not, then create a new one and create file launch.json in that. Now you have launch.json for your workspace and you can configure your project.

Open folder in Explorer from VS Code

Say I have a project/folder open in VS Code and I want to open the folder in Windows Explorer, is there keyboard shortcut or a VS Code Extension for that? Sometimes I also need to go to the project folder in command prompt.
In Visual Studio 2017, there's a menu option to open the folder and an extension for quickly getting to the project folder in command prompt -- see below:
How do I handle these in VS Code?
Right click on a file or folder from the left side explorer of VSCode, then select "Reveal in Explorer". Now you can see the folder in windows explorer.

How can I cleanly remove Workspaces in Visual Studio Code?

I'm on a MAC and remove workspaces with the terminal in the folder ~/Library/Application Support/Code/User/workspaceStorage, but i don't think it's the clean way.
Can someone explain me how I can remove cleanly a workspace and all its files from my mac?
I miss this feature. I can add many workspaces, but where is the "delete button"?
I use Visual Studio Code V.1.28.2 on macOS Mojave 10.14.
You can use the command palette:
Menu: View > Command Palette... (or F1)
Search: "Workspaces: Remove Folder from Workspace..." and select the folder you want to remove.
Hope this may help you
Visual Studio Code 1.32.3. Windows 10.
Here's the answer from the Twitter account of Visual studio code:
You have just to go to the Explorer section and remove any folder or file in it see the image below:
right click in the workspace you'd like to remove and select the "Remove Folder from Workspace" item; the name of the workspace will become: "NO FOLDER OPENED" that is the one you'll get when you installed the very first time Visual Studio Code.
If none of the above solutions works ...you can go to file -> close folder.
It will close the workspace folder and you can add any new folder to the explorer, like the first time you install visual code
find workspace.json, it will be inside the workspace you had created workspaces->[unique number]->workspace.json . you can edit the workspace directories in it.
The only other relevant answer is this .
The Workspaces is stored at %userprofile%\AppData\Roaming\Code\User\workspaceStorage (Windows) , none of the mentioned actions will delete them .
There also can be a .code-workspace Workspace File or "Workspace Config", which can be moved anywhere . And .vscode Workspace Folder/-s in the folder/-s which was added to the workspace .
Deleting all existing of these 3, and the relevant items from : %userprofile%\AppData\Roaming\Code\storage.json and all %userprofile%\AppData\Roaming\logs<< .. >> . Will be a workspace deletion .
It seems that workspaces are either open or closed, you can close them from the main menu. To cleanly delete a workspace, just remove the workspace file from disk also.

Visual Studio Code in Explorer's context menu

I want to be Visual Studio Code my default editor for all text-based file types in Windows. For Notepad++ there is an extension in the Windows Explorer to provide "Edit in Notepad++" for each file.
How can I achieve this for "Edit with Visual Studio Code"?
Do I have to "program" such extension on my own or are there any ready-to-use solutions available?
According to this blog post you can set this option during the installation process. If you want to add this option afterwards you either can follow the instructions of the rest of the post or (as recommended) reinstall vscode and then select that option during reinstalling.
When I faced the same issue, for me it was more comfortable to simply reinstall vscode.
It is east !
step 1 -->
Right click the file you want to always open with VS code
example - if you want to always open .txt files in VS code then Right click on any .txt file that is in you system
see this
step 2 -->
click on 'open with'
see this
step 3 -->
click on 'choose another app'
see this
step 4 -->
a new window will open, it will show all the applications on you system that are capable to open that file
click on VS code
and check the box at the bottom that says 'always use this app to open .txt files'
see this
and then click on open
THATS IT
NOW ON .txt FILES WILL BE OPENED IN VS CODE
.txt file extension is just an example, you can do this to any file example .py, .html, .pdf etc.

Empty Sidebar on Visual Studio Code on File -> Open

I have been using Visual Studio Code for sometime and its really amazing so far. But often I stumble upon an issue where if I import project through File->Open I end up with empty sidebar. If I do cmd+P to load files, files are available but its just not visible on sidebar.
Trying open projects with File->Open Recents or Ctrl+R also dint work out.
After reporting the issue to Visual Studio Code's github link, they have resolved the issue pretty fast.
Reason
Users who had file explorer hidden in 1.15 release might not see file explorer and also cannot retrieve it after upgrading to latest version. Workaround is to upgrade to insiders containing the fix or clear cache for that folder as follows:
Steps
Close the window opening the folder that has this issue
Open new empty Window
Run command Developer: Toggle Developer Tools
Go to Application Tab in Developer tools
Select file:// under Local Storage section in the menu on the left
Search for the key workbench.explorer.views.state using Filter inputbox
Select the folder with this key and Delete it
Now open the folder in VS Code and you should be seeing the file explorer.