What files in Eclipse contains code templates and keyboard bindings? - eclipse

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

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.

How can I search for a file in just one specific folder in VSCode when using a workspace with multiple folders?

I'm using the workspace feature of VSCode, with two projects, but it's annoying to search for a file in the front-end project and need to pass by back-end files to find the one I want.
I'm using ctrl + p to search for files.
How can I search for a file in just one folder with multiple projects opened in the workspace?
Yes thats possible: use a relative path: ./mySearchedProjectName in "files to include"-input
from HERE!
UPDATED answer to UPDATED question
The fuzzy file finder (CTRL+P or ⌘+P) somehow supports prefixing the filename with a folder, such as folder/filename to locate a file from a specific folder:
But, in my experience, the search is a bit lacking. For example, I find it usually can only find files this way if that file has been recently opened in your workspace. It also does not support regex.
The best thing that can be done is to enable including recently opened files by adding this to the workspace settings:
"settings": {
"search.quickOpen.includeHistory": true,
AFAIK, there is no other built-in way to filter the results. There are (still) open feature requests for this, like this Allow quick open to filter on folder names by typing folder name after the file. You can thumbs-up them to hopefully get them noticed.
ORIGINAL answer to ORIGINAL question
I don't know what you mean by "projects" since VS Code only has "workspaces" and "folders", such that you add folders to a workspace. I think you're already doing this, where each folder contains a separate set of codes.
With that said, the Search/Find panel has an area to specify files to include, where you can limit your search to a specific folder. For example:
Here I have 3 folders (proj 1-3) added to a workspace. I have 3 sample files with the same text.
When searching, you can set files to include to a specific folder (./proj2), so that the search results will be limited to that folder.
I've found the best solution to this for me (though it's still a sub-optimal one) is simply to run multiple VS Code instances, one for each folder.
It's a pain to start up, but once you get things going (and hopefully you're not restarting often on your dev machine, so this is less of an issue) it works perfectly: you can search for files with only the relevant ones showing up.
Also, if you want to reduce the start-up pain you can make a shortcut/alias/etc. in your operating system that starts both at once.

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.

Sublime Text: quickly access files outside the current project

To facilitate code reuse across projects, I set up this (quick and dirty) method to access recent projects.
In the current project, I add a link (z-themes) to a folder that contains links to recent projects. This enabled me to access those files without having to open the whole project (this worked in Espresso).
In Sublime Text, links are not followed and symlinks mess with the file search (files in the linked folders appear in the Go to file panel, so I might open the wrong file)
The question is: how do easily I access files in predefined folders outside the current project?
Plugins and alternative workflows are welcome.
Perhaps something like FuzzyFileNav? That plugin allows you to set up bookmarks to a particular folder. You can then navigate through folders as you would normally in the file system.
I found Goto Folder: it's very simplistic and doesn't allow for any file management like FuzzyFileNav does (which could be nice) but it allows for simple bookmarks and it behaves well.
Edit: I also found FileBinder
This is what I use now: I created a previous projects "project" just for the older files.
simple to add projects (drag their folder to the sidebar)
use Sublime's file search across all the files
old projects' files are separated from the current project
no plugins to update/figure out
Only thing is that I'll have to keep a separate window open just for this, but it's not a big deal.

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