Where is the editor layout stored in VSCode? - visual-studio-code

Whenever I open a folder that I've already worked in, VSCode is clever and reopens it in the exact same layout I already had it. However, I have absolutely no clue how it does that - I can't find a config file or anything anywhere, which is something I'd love to have; in my specific usecase I create a lot of workspaces and they all have the same sort of structure, so if I could save that layout so I didn't have to recreate it every time it'd be great.

The answer ends up being super annoying... they're stored in %APPDATA%\Code\User\workspaceStorage in some hashed looking folder names, which contain a pretty useless workspace.json file (all workspaces) and all other info stored in a *.vscdb (and its associated *.backup file), which is a SQLite Format 3 file storing all that information. It's barely used as a database from what I can see, a json file could do just as well, but I digress...
tl;dr they're a pain to get out.

VSCode mainly saves all of the preferences and user choices in the settings.json file. Moreover, you can actually set your preferences in VSCode Settings. But if you want to copy/paste your workspace settings to different workspaces, I guess the best choice would be to look at your settings.json layout settings.
Go to File > Preferences and adding them in the right pane, in "User Settings" if you want to keep them for all workspaces or in "Workspace Settings" for this workspace only.
To see settings for layouts and explorer, search for explorer.
You can read more about settings.json defaults and attributes exposed here

Related

Where are the information about each workspace stored?

I know that some settings such as imported folders are store on the workspace file such as my-worskapce.code-workspace and some others such as python interpreter are stored in the root folder(s?) such as .vscode/settings.json but these do not include information about opened editors or which extensions are disabled for each workspace etc. Where can I find those information?
I need that information because I started storing all my *.code-workspace files in ~/ and now it's getting cluttered and I want to move them to a different folder, when I do, and reopen my workspace, I see that all open editors are gone! This hurts my productivity as I will have to reopen them and recall which files were being worked on. And another issue is that previously added folders are gone too! I have to re-add them which is merely a redo of work that already has been done, since imported folders are imported as relative paths. If I move the *.code-workspace file to it's original location with the same name however, everything is back to normal, so this tells me VSCode is storing information about each workspace somewhere and it's bound to each *.code-workspace absolute path. I have checked ~/.config/Code/User but couldn't find anything. I've googled a lot using different keywords but seems it's nowhere documented or asked about. I usually make backups of my workspace files and I'd like to make back up of these information as well.
In windows you can find them in
C:\Users\<username>\AppData\Roaming\Code\User\workspaceStorage
VS Code 1.75 introduced a new Profiles feature, summarised here.
Profiles store information such as user settings, installed extensions and the current layout of panels etc.
You can export/import profiles to/from a Github gist or a local file. Different profiles are associated with each workspace.
Profiles won't resolve all your immediate issues, but may give you more flexibility in the future.

VS Code does not see existing file

Apparently VS Code does not list existing files in files dropdown (Ctrl + P command).
Here is what it shows:
As you can see, the file laravel-2019-09-26.log exists in the directory (left bottom), but not in the files dropdown. After I open this file from the Explorer tree, it starts showing in the dropdown.
Am I doing something wrong or does this happen for everyone? Or is this command supposed to show previously opened files only? If so, what is the way to quickly open any existing file in the workspace?
N.B: I have gone through this related question. No one has mentioned this problem, making me think that this might be specific to my machine.
Edit
For future readers, second answer provided by #michaelze is spot on. VS Code by default does not list files mentioned in .gitignore. You can change this setting by going to Settings panel (File > Preferences > Settings) and typing useIgnoreFiles. This will bring up two boolean settings named Use Global Ignore Files and Use Ignore Files. Turn off these two settings and all workspace files will start showing in the files dropdown. Works correctly as of version 1.38.1.
As those files are .log files, I assume, they are maybe mentioned in the .gitignore file? Maybe this can help you? Visual Studio Code - Automatic exclude based on .gitignore
The list you are seing when pressing CTRL + P is called recently opened. When you open one of the files, it was recently open, so it shows up. The CTRL + P menu also has a files results section that lists actual search results from the files you have in your workspace. None of your .log files are showing up in this section (hence the section is not visible).
The laravel-2019-09-08.log file is also missing from the drop down.
I was wondering if maybe the listing is capped to a certain number of files. Try to be more specific with your search. In my version of VSCode, I can search for files using multiple words. Maybe try searching for "laravel 26" to find the file you are looking for?

Eclipse syntax coloring settings gone.

I use customized syntax coloring for my Eclipse editor and it has reverted back to the default settings. This is the second time in a couple weeks that it has happened. Any ideas as to why this is happening or how I can get my custom settings back? I have a very specific coloring scheme that I like to use and it takes forever to manually set!
Are you switching across workspaces? As I understand eclipse preferences are stored in .settings/ present in workspace's root directory.
I export eclipse preferences and import it when I switch workspaces. Another cool trick I found is to close projects when I do not use them.
Eclipse official link on how to export preferences:
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftimpandexp.htm
Sometimes simply import/export would not be enough, so you may need a list of .pref files where the syntax coloring settings are stored. What I have here is not complete and I just list what I use and I hope it helps.
(I process .java, .jsp, .xml, js and .properties files.)
You can find them by searching .pref files in your workspace. Remember to adjust your searching options to look into subfolders.
org.eclipse.ui.editors.prefs
org.eclipse.jdt.ui.prefs
org.eclipse.ui.workbench.prefs
org.eclipse.wst.xml.ui.prefs
org.eclipse.jst.jsp.ui.prefs
org.eclipse.wst.html.ui.prefs
org.eclipse.wst.jsdt.ui.prefs
org.eclipse.ant.ui.prefs
org.eclipse.datatools.sqltools.sqleditor.prefs
org.eclipse.debug.ui.prefs
org.eclipse.php.ui.prefs
com.adobe.flexide.mxml.core.prefs
org.python.pydev.prefs
com.adobe.flexide.as.core.prefs
com.adobe.flexide.css.core.prefs
org.codehaus.groovy.eclipse.ui.prefs
org.epic.perleditor.prefs
org.eclipse.cdt.ui.prefs
You may copy them when you finish adjusting your syntax coloring settings. When needed, search .pref again to get access to their locations, and restore your settings by copying the lines with color code, in order to avoid unpredictable side effect. As I can see this is the only way, inconvenient buy effective.

What files in Eclipse contains code templates and keyboard bindings?

I have three common workplaces where I use the Eclipse IDE.
A nice trick when using multiple common workplaces is to copy certain configuration files to Dropbox, and link to them in the original configuration location. This way, all settings and changes are instantly available in your other workplaces.
You've got your workspace with a whopping 100 megabytes of files. You've got your .eclipse which is closing in on 200 megabytes.
I would like to know which specific files contain my custom javascript code templates, and which contains my keyboard shortcuts, so I can share these, and only these, with myself through Dropbox.
Ideally, I'd like a list of of certain settings and their locations so I can choose to share more. But I haven't found something like this on Google.
Why am I not just sharing my entire workspace and configuration directory? Well, first, it is crazy big. Second, Eclipse is modular. In some places I use certain modules that I don't use elsewhere. And you all know that modules/plugins are a crazy mess of files and configuration from which there is no escape.
You can try to export Eclipse preferences from one workspace and export them to other workspace. If it doesn't work for your, enter a bug against corresponding Eclipse project.
I figured it out.
You can copy your ~/workspace/eclipse/.metadata to somewhere. Change a preference, and sync your workspace to your backup in order to find out what files are changed.
You'll find that a lot of settings are in ~/workspace/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/. The javascript templates and other javascript options are in ~/workspace/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.jsdt.ui.prefs
org.eclipse.wst.jsdt.ui.prefs = Code Templates
org.eclipse.jdt.ui.prefs = Syntax Coloring
org.eclipse.ui.editors.prefs = Text Editors

Eclipse syntax highlighting preferences save and restore

I spend some time customizing the colors for syntax highlighting in Eclipse (Java, JSP, HTML, CSS, etc.) but whenever I try to export these settings via File|Export|General|Preferences and reimport them, the settings never completely get imported back. Some colors are restored and others are left unchanged, leaving me in an 'in between' state - very frustrating.
I'm using Eclipse 3.4 Ganymede, by the way.
Has anyone found a reliable way to save and restore Eclipse syntax highlighting settings?
I finally figured out how to do this.
I just wanted to mention beforehand that I did try to start with a fresh Eclipse install, export the preferences to a .epf file, change just one single setting, export again, and compare the files. To my surprise, trying to import settings from a minimal .epf file did not work reliably either.
The solution that worked for me was to copy these files: {Eclipse workspace directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings/*.prefs
I tried a fresh Eclipse install on another machine and after copying those files over, all my settings were restored perfectly.
The solution was to copy SOME - not all - of the files from {workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/*.prefs into my other workspace.
In particular (per the https://stackoverflow.com/questions/96981/color-themes-for-eclipse thread):
org.eclipse.jdt.ui.prefs = Syntax Coloring
org.eclipse.ui.editors.prefs = Text Editors
Copying other files caused things to break.
There are a couple of notes to add:
I had to copy the aforementioned pair of files several times before I got the correct syntax coloring.
Be sure to close the workspace, if it's open in Eclipse, before copying the files.
This worked with Eclipse Helios.
If you want to be a little more fine grained on what you migrate, the syntax highlighting rules are the lines starting with semanticHighlighting on workspace-indigo/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs
Doing this, I was able to migrate my syntax highlighting from Helios to Indigo
I'm using JBoss Developer Studio 10 with the Eclipse Neon 4.6 engine.
All .prefs files are inside this path:
/workspace/.metadata/.plugins/org.eclipse.core.runtime/.sett‌​ings
Update: I found a similar structure on this path too:
\RedHat\JBossDev\studio\configuration\.settings
It's my IDE folder plus \configuration\.settings
I recommend search for org.eclipse.*ui*.prefs instead *.prefs to refine your result.
The principal config files are:
org.eclipse.jdt.ui.prefs
Java Syntax Color Settings
org.eclipse.ui.editors.prefs
Text Editor Settings
org.eclipse.cdt.ui.prefs
Formatter Settings
org.eclipse.wst.jsdt.ui.prefs
JavaScript Syntax Color Settings
org.eclipse.jst.jsp.ui.prefs
org.eclipse.wst.css.ui.prefs
org.eclipse.wst.html.ui.prefs
org.eclipse.wst.json.ui.prefs
org.eclipse.wst.dtd.ui.prefs
org.eclipse.wst.xml.ui.prefs
org.eclipse.wst.xsl.ui.prefs
If have a problematic workspace:
Copy the files above
Create a new workspace
Copy and Replace that files in your new workspace
This will recover perfectly your custom editors color settings. For me worked very well.
Eclipse CDT stores 'Syntax coloring' in the file org.eclipse.cdt.ui.prefs
This is located for example here: C:\eclipse\workspace.metadata.plugins\org.eclipse.core.runtime.settings\
Copy and paste over the top of the one in your new eclipse instance. This worked for me when moving from 3.4 to 3.5
I would export the preference before modifying the color, and then after.
That way, you would be able to isolate the specific rules of an eclipse preference file into one smaller file and:
check if some colors not restored are indeed represented by a rule
the import of a smaller preference has any effect on the previously unchanged settings.
That kind of strategy can be further refined into several small settings files (one for Java, one for JSP, HTML, CSS, ...), in order to better analyzing the potential side-effects when re-importing those settings.
I have had success in importing Eclipse Helios's syntax highlighting rules by copying the file:
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs
from the source workspace to the target workspace. It seems this file also contains Eclipse's code formatter profiles and code templates.
Environment:
Version: Helios Release
Build id: 20100617-1415
(on linux)
Once Michael Bosworth's answer helped me to some extend and I voted up. But now I see some obligation to answer it myself, because copying these two files are not enough. Let me explain why.
First, these files contains lines irrevelente to syntax coloring.
Second, syntax coloring for other editors are located elsewhere, for example, those of XML files are in
org.eclipse.wst.xml.ui.prefs
and those of HTML files:
org.eclipse.wst.html.ui.prefs
JSP pages?
org.eclipse.jst.jsp.ui.prefs
, etc.
Third, when we change font colors, usually we change background colors, line highlighting colors, etc. to get a clearer view of codes. This involves more files.
If we search *.pref files in path
/workspace/.metadata/.plugins
we can find all preferences files where we can locate all lines of coloring settings. But by copy-pasting all these files to another workspace can also trigger problems, for they are not exclusively syntax-coloring-related. Moreover, when we are switching between two versions of Eclipse, unexpected problems may arise.
So, the safest way is:
Create a new workspace if you don't have one.
Open all *.pref files we find in the workspace one by one,
Copy those lines containing color codes,
Find the same file in your new workspace,
Replace the color part by existing one. Or, set the colors in Eclipse, by assuming the corresponding options according to properties' name. All color codes are RGB based.
EDIT: (2017.02.24)
Eclipse Mars has a plugin Oomph, which can record your preference settings to provide seamless transmission of your preferences. When you activate it, every time you change a value, it prompts to ask you if you want to record it in Oomph, providing you the exact line in the corresponding file where your new value is stored. So, when you install Oomph, you can:
Change the settings of your font face, font size, background color, etc.
In the prompt windows of Oomph, take note of the location of your new settings. (Because if you tell Oomph to remember your settings, it will not prompt never again, so you may only see this windows once.)
I have deleted recently changed *.prefs file from the following dreictory \myworkspace.metadata.plugins\org.eclipse.core.runtime.settings\ and imported existing exported preference.
I am the first person, who answer for this question as per my knowledge :), Cause even I struggled lot.
Thanks
I faced the same problem few days ago.
The easiest way to restore the defaults is to import the default theme again, which you can find under:
http://eclipsecolorthemes.org/?view=theme&id=790