Visual Studio Code .vscode directory disappeared from workspace - visual-studio-code

Today when I opened my workspace in VS code, one of my extensions displayed an error message, telling me that there is some option missing in settings. I went looking for it in settings.json, just to find out my whole .vscode directory is gone along with settings.json file in it, and now I have to create everything from scratch once again. I checked reciclyng bin, it wasn't there either. I don't know whether it's a VS code problem, or somme Windows 10 shenanigans, but I can't be sure this won't happen again, because I have no idea how it happened in the first place.

If you are working on a collaborative project with colleagues or other devs then someone might have changed the settings in .vscode/setting.json
Check this issue
You can exclude files and folder to hide in workspace by adding files.exlude in the settings.json file

Related

How do I stop VScode from creating the .vscode folder inside my source folder

VScode keeps creating this weird .vscode folder inside my source folder where my code is, it's super annoying and I want nothing to do with it. For some odd reason deleting it caused my program to bug out, of course I thought it was my code but I ctrl-z the entire code back where I started and it still did the same thing.
And I'm not using any build in compilers in vscode.
I've found the best thing to do here is setup a global .gitignore file and add .vscode to it https://sebastiandedeyne.com/setting-up-a-global-gitignore-file/

VSCode: Searching into all project content

Since VSCode version 1.31 I can't find anything into my project files. I've already reinstalled the VSCode App on my Mac, but nothing happened on it.
This option doesn't work without open the files before:
https://code.visualstudio.com/docs/editor/codebasics#_search-across-files
I've been searching on the web, but I didn't find anyone with the same problem as me.
Please, help me!!
To make all your files visible in search you must always make sure all the necessary files are present in the same director. And then as Renee stated in the comments above, you should add your working folder to the Workspace or open folder from the start screen. Below are the screen snippets of the Visual Studio code's start screen from where you can file Add Workspace Folder button. If it is not found, you can always find it under File menu.

How do I prevent vscode from creating workspace files such as ".vscode/settings.json"?

Whenever I open a new folder to edit some code (code .), opening the settings dialog (⌘+,) immediately creates a directory .vscode with a mostly empty file settings.json.
Since there are no workspace-specific settings, the file looks like:
{
}
For the time being, I do not want to have .vscode directories spread across my filesystem. I am happy with global settings.
Is there a way to disable this behavior and prevent Visual Studio Code from creating these files automatically?
Currently this isn't an option, but it is an open issue (see here). This post also contains some work-arounds for git projects.

Tasks are only available on a workspace folder?

Can't find an simple, basic solution anywhere for this problem so I figured it was worth posting it here.
When I go to run my code as a task, I get the following message: "Tasks are only available on a workspace folder" - I can't find a solution anywhere and I'm a beginner at Visual Studio Code so I might need the answer / solution explaining in more simpler terms.
VSC Version = 1.17.0
Visual Studio Code treats the folder containing your program file as a workspace folder.
Your tasks created will be contained in a file tasks.json within a hidden folder .vscode inside your project or workspace folder.
So instead of opening the file directly to create a task, you need to open the folder as a project.
The "Workspace launch configuration" section of VSCode mentions:
With multi-root workspaces, VS Code searches across all folders for launch.json debug configuration files and displays them with the folder name as a suffix.
Additionally VS Code will also display launch configurations defined in the workspace configuration file.
Example of settings: vscode-tslint/vscode-tslint.code-workspace
As an alternative, you can have User level tasks to share them across projects since VSCode 1.42 (Jan. 2020).
But regarding workspace tasks, since VSCode 1.57 (May 2021), said tasks will have to be "trusted" by anyone opening the same workspace, assuming you have versioned and pushed the .vscode folder.
Safe code browsing
It's great that there is so much source code available on public repositories and file shares. No matter the coding task or problem, there is probably already a good solution available somewhere.
However, using open-source code and tools does have risks and you can leave yourself open to malicious code execution and exploits.
Workspace Trust provides an extra layer of security when working with unfamiliar code by preventing automatic code execution when a workspace is open in Restricted Mode.

Disable Auto Generation of .vscode Folder

I often like to use VSCode to quick view some projects to pull snippets from them. However, this leads to a ton of additional .vscode folders being placed on my drive in any folder I use the right-click -> Open with VSCode option.
Is there a way to disable this folder from being created every time vscode loads somewhere new?
This issue was due to the 'C/C++ for Visual Studio Code' extension being outdated.
Upgrading to the latest version of this extension has fixed the problem.
That is not the standard behaviour of VSCode, normally the .vscode only gets generated once there is something like a launch.json put into it. Mind checking what's actually in there?