How to access Visual Studio Code extension settings - visual-studio-code

Got myself Visual Studio Code. I've installed a Uncrustify extension to make my files be formatted when I edit them. I wanted to make it format my files on save, but I cannot open like Options menu for this extension or something like that. The author gives this screenshot:
But I cannot reach that menu. When I click on this little gear circle near the extension under the Extensions tab, it just pops up a menu with: Disable (Workspace), Disable (Always), Uninstall. I can only edit 4 things, like my .cfg file path under Ctrl+Comma settings, but that's not what I am searching for, and it's not what is on this screen provided by author
I guess I am not only asking about this particular extension, but generally for extension settings in this editor.

Many ways mentioned here in an issue created available on VSCode repository: Allow to change settings from Extensions editor.
On Windows, I could be able to change settings by going to:
File -> Preferences -> Settings -> Extensions.

Dont know if you figured it out yet or not but maybe for someone who comes here to find an answer.
Step 1: Press ctrl+alt+p to open the command pallet.
Step 2: Search and execute this command Uncrustify: Open config file
If your config file has not been created, then before step 2 you must execute Uncrustify: Create default config file command.
Anyways, these instructions are present their in Details section of the extension.

Related

How to add "onView" "Settings" Page as ActivationEvent for vscode Extension?

The title is the TL;DR, but I'll start off with intent, I'm working on a vscode extension that have configuration/settings that will have an initial auto-detection (on activation) and populated during runtime, eg. selectable version of application installed on the computer (such as LLVM that could have 13 and/or 14). The closest is something like the built-in git extension's executable path detection.
So basically this runtime detection means I cannot use the configuration contribution points as everything in package.json is hardcoded...
Back to activation, the extension can be activated on any few commands indicated in the activationEvents, but the main thing is the detection must be done prior to users opening the Preferences: Open Settings (UI), I've looked through the vscode repo and found onCommand:workbench.action.openSettings2 to be closest to what I need, however I found a niche scenario where if the user have "Settings" page opened prior to installing the extension and relaunching vscode will jump straight to the Settings page, this will not activate the extension.
I checked the built-in git extension and found that they have been using "*" which is not recommended, so I'm using onStartupFinished as a workaround for now.
I found onView may be what I am looking for, but how do I know what is the editor/webview name for "Settings" page - onView:xxx.openSettings?

Recover lost settings + extensions and more?

I was playing around with my VSCode Settings Sync, and accidentally replaced my settings.json file with another one from a fresh install, as a consequence, I lost my entire settings.json configuration.
Is there a way to recover the lost settings.json file?
I checked my backups, however, it seems that I one cannot go back into the /Users/mf/Library/Application Support/Code/User/Sync folder.
Yes you can get them back.
They are saved on the hard-drive if your settings are set to their default values.
The universal method (works the same for all systems) is to hit the [F1] key, then type the command below into the input, until you see the option. When you do see the option click on it to open the directory.
Settings Sync: Open Backups Folder
The other option you have is to view the data in VSCode using the following VSCode command from your quick input using the [F1] key followed by the same instructions for the command above.
Settings Sync: Show Synced Data
There should be several saved versions of your settings, unless you have changed your configuration for settings sync in the settings menu, or in your user/workspace settings.json file.
Personally I like to just open backup folders and pullout what I need. If you are like me, and you use Ubuntu then the path below is the path used by VSCode to store backed-up keybindings & Settings.json instances. You can pullout what ever you need from that directory.
~/.config/Code/User/settings.json
If you need to restore the backed up files, you can visit this link, it demonstrates how to return to a previous editor configuration:
RESTORE PREVIOUS VS CODE CONFIGURATION:
https://code.visualstudio.com/docs/editor/settings-sync#_restoring-data

How to change folder that opened by default in VSCode?

I have small problem with VSCode folder, that opened by default.
Problem description: I start new instance of VSCode (trough File->New Window), and then if I choose File->Open Folder it opens dialog with my Windows user folder as starting point (C:\Users\MyUser)
Question: How can I change that folder in settings (if it possible)? So by default it will show as start point for example D:\development\ ?
At the time I write this answer, this is not possible. There are two problems on Windows, and one problem on Mac and Linux:
VS Code does not provide a default path to the file dialog 1. It does remember the last folder that you opened a file in, but that path cannot be used as a default because it is overwritten constantly.
On Windows only, Electron ignores the default path when creating a file dialog if the default path is a directory 2.
An extension also cannot solve this, because extensions are not allowed to modify the File menu 3.
I think the best option at this point is to pin a folder to the Quick Access area in Windows Explorer, as suggested in a comment, or to put an actual shortcut in the user profile folder.
Workspaces and File > Open Recent may also be helpful if you often open the same folders.
Your main problem is that you are unable to open your specific folder in VScode.
To solve that you can simply open the terminal/cmd in that specific window by just typing cmd in your search bar or just by pressing shift+right-click in that folder.
Now your cmd is open and you just have to type "code ." in the cmd and press enter to open the current folder in your VSCode.
In case that code . doesn't work for you then you have to add the Vscode in the environment variables of your windows.
Visual Studio doesn't provide a specific feature to open a specific path. But there is a solution to your problem. You are saying that you want D:\develpment as a default when you open VS Code. You can go to that specific directory or create shortcut to desktop then click right click on that folder and then click on open with code. If you didnot see open with code then reinstall your VS code and check on open with code when you are reinstalling VS Code.
make a shortcut on the desktop for vscode and then modify it and add the folder after the .exe command. This will default open that folder when you double click on it.
Visual Studio Code can be installed in two ways - User setup and System setup. I strongly believe you have User setup installed in your PC. Try re-installing it System-wide. That should probably fix your problem.
For more information: https://code.visualstudio.com/docs/setup/windows#_user-setup-versus-system-setup
PS: A lot more information is needed, you can share a screenshot of the window and elaborate more on it.

Visual Studio Code edit file

When I try to edit a file in visual studio code, I type the command 'code filename.ps1' and the code used to automatically open as a second tab in the editor.
Now, when I do the same thing, it opens in a new window. I have not changed anything in my settings and I can't find an associated Preference that controls this.
Anyone know exactly the default setting that I need to look at?
According to CLI Options this should work:
code -r filename.ps1
>
-r or --reuse-window
Forces opening a file or folder in the last active window.

How to prevent Visual Studio Code from always reopening the previous files or folders?

Visual Studio Code always seems to remember my session and reopen the files and/or projects that were open the last time I used it. It obviously behaves correctly when running it from the command line with a file or folder supplied, but when opening from a taskbar shortcut, I'd like it to default to an empty environment.
Is there any way to change this behavior?
You can also go into your settings and use the following:
"window.reopenFolders": "none"
which will not reopen the folders you were working on when you closed the editor. The other options are one (the default) and all.
Edit 2017-11-09:
The option is now changed in latest versions.
"window.restoreWindows": "none"
See Mathieu DOMER's answer.
Edit 2018-09-12:
Another setting related to this is the hotExit setting. This has been discussed in this answer to a related question. To prevent reopening and remembering unsaved files, you can set this to:
"files.hotExit": "off"
But from the test I've made, when the window.restoreWindows setting is set to none, this is not needed. I haven't tested every possible combination, so YMMV.
And to answer a question in the comments, to edit the settings, you have to open the settings file. Some documentation can be found here (at least on the date I am writing this).
Edit 2022-03-16:
If you prefer using a GUI to change the settings, see D'Arcy Rittich's answer.
In VS Code:
for Windows/Linux Ctrl+, (or choose File/Preferences/Settings) to open the settings page.
for Mac ⌘+, (or choose Code -> Preferences -> Settings) to open the settings page.
then type restoreWindows in the Search settings input to filter for this setting. Set it to none and restart VS Code.
With latest update, it seems that the parameter has changed, now use:
"window.restoreWindows": "none"
You can add the -n option to the startup of VS Code and it will always start with an empty window, not restoring your previous session.
01 December 2018
This works for me. i.e. "C:\Users\Sampath\AppData\Local\Programs\Microsoft VS Code\Code.exe" -n
For me, none of above is working while I'm trying to close "dirty" unsaved files which I accidentally edited 1000 files and wanted to ignore saving all of them.
My fix was adding this line into settings.json:
"files.hotExit": "off"
Open up vscode, close vscode and just click the confirmation button to close all of the files without saving.
Then open back vscode and boom.. no more unsaved files being shown.
If "window.restoreWindows": "none" not solve the problem,then try to run code as root -> sudo code --user-data-dir code files and restart code normally without root.
Below worked for me
Right-click on Shortcut and add --disable-gpu to Target as per screen shot.
For me the only solution that worked was to go to the solution root and delete the .vs folder.
I reinstalled Visual Studio Code by downloading the latest update. I did not have to uninstall the previously installed Code. It work ok for me now.