IN Eclipse i want to chnage the default editor of some .htm files.
If i try to go to FIle Association and assiciate the default editor then file gets opened in that new editor but i don't get the syntax highlighting.
The solution is that the file association is locked ny some plugin editor
Preferences -- Context type----text ----Your editor -- reomve the extension
But i get the .htm(locked) so i cant remove it.
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Freference%2Fref-content-type.htm
Note: Certain items will be marked as "locked". An item is locked if
it is one of the associations provided by the plug-in that declares
the content type. In other words, you can remove only user-contributed
associations.
Is there any way to remove those locks even thought it can be hackish way but i want to do it
You don't need to "unlock" an existing association to add a new association and make it the default.
Add a new association via the "Add" button
Select the new entry
Hit the "Default" button to make your new entry the default editor
Could it be, that you want to change the "File Association"? This can be done in General / Editors / File Associations. BUT Eclipse uses at least one default-editor and this is the reason for the "locked"-message in the "Content Types". You could set the "Text Editor" to all unwanted types. Looks like a workaround, but makes sense, because it is the same as the file associations of your operating system, that asks you for the program to display the file.
Another question is, why do you want to unlock or remove the "Content Type"? Does it change anything in the Eclipse logic?
Go see this answer from "Greg Desmarais" (assign the desired editor to "default")
https://stackoverflow.com/a/15642583/162094
Related
VS Code is aware of many file types, but I cannot find any information on where to see all file types it currently understands.
I want to see which file type is associated with which language.
If I view the file associations it's totally blank:
I want to add a new association. I want to associate *.inc as a restructured text file. But figuring this out is a guess right now, what is the "code" for the restructured text language?
Is it rst:
Or is it "restructured text"? Or another value. My VS Code currently associates *.rst files with restructured text, but I cannot see that configuration anywhere.
The easiest way I've found for a global association is simply to Ctrl + k m (or Ctrl +Shift + P and type "change language mode")` with a file of the type you're associating open.
In the first selections will be the option "Configure File Association for 'x' " (whatever file type - see image attached). Selecting this gives you the option to choose the language and will then make the filetype association permanent.
screenshot
This may have changed (probably did) since the original question and accepted answer (and I don't know when it changed) but it's so much easier than the manual editing steps in the accepted and some of the other answers, and totally avoids having to muss with IDs that may not be obvious.
Answer 2
In VScode, you can add persistent file associations for language highlighting to your settings.json file like this:
// Place your settings in this file to overwrite the default settings
{
"some_setting": custom_value,
...
"files.associations": {
"*.thor": "ruby",
"*.jsx": "javascript",
"Jenkinsfile*": "groovy"
}
}
You can use Ctrl+Shift+P (or View -> Command Palette from the menu) and then type settings JSON. Choose Preferences: Open Settings (JSON) to open your settings.json.
To find the proper language ID, use Ctrl + Shift + P (or View -> Command Palette from the menu) and then type Change Language Mode. You can see the language ID in the list, e.g. type docker to find the language ID for Docker files (dockerfile). In the first entry in the example above, .thor is the file ending, ruby is the language ID.
I'm building a VS Code extension which includes changing the name/title of untitled-1 tab (unsaved file).
I tried running the below code in debugger console of extension but it didn't reflect in the editor:
vscode.workspace.textDocuments[0].fileName="myFile"
Is it not possible or am I missing something?
It is still (Q1 2020) not possible, but the next VSCode 1.42 will name its Untitled editors differently.
Untitled editors in VS Code are text buffers that have not yet been saved to disk.
You can leave them open for as long as you like and all text content is stored and restored between restarts.
Untitled editors were given generic names such as Untitled-1 and counting upwards.
In this release, untitled editors will use the content of the first line of the document for the editor title, and include the generic name as part of the description:
Note: If the first line is empty or does not contain any words, the title will fall back to Untitled_* as before.
So while you cannot set the title yourself (still readonly fileName), technically... changing the first line of that file would be enough to change the title of said "Untitled" editor.
With VSCode 1.43 (Q1 2020), a new setting workbench.editor.untitled.labelFormat allows to control whether untitled editors should use the contents as title or not.
Possible values are content or name.
Configure 'workbench.editor.untitled.labelFormat': 'name' to get the previous behavior back where untitled editors would have a short title, such as Untitled-1.
It's not possible - if you check out the source code for the API definition in vscode.d.ts, you'll see that fileName is declared as readonly:
export interface TextDocument {
// ...
readonly fileName: string;
// ...
}
Unfortunately, it seems that the readonly attribute isn't reflected in the API docs on the website.
This mainly happens if we create a new file in the OPEN EDITORS section, thus they appear as unsaved. To prevent this, create a folder for storing your files, and then in that folder, create your new file then it will show options to name it, also you can add a file type extension like .cpp.
TIP: vsc-rename-files extension to rename your files.
I am implementing refactor action for my custom eclipse editor. When the file is renamed, I reset the editor input based on the renamed file and also update the part name.
However the editor references still hold the previous input and file names. Thus eclipse does not know changes to the editor window and cause problems later on like "empty editor tab" exceptions.
How to update the editor references for refactor actions on eclipse editor?
In your class derived from EditorPart do something like:
IEditorInput input = ... new editor input
setInputWithNotify(input);
setPartName(input.getName());
firePropertyChange(PROP_DIRTY);
I've been having this problem for some time and have never bothered to fix it since Eclipse has a horrible help system and I can't seem to find the right Google keywords to find what I need.
My problem is that when I refactor a class name, eclipse looks for all potential locations of that name and replaces them.
For instance, if I have a string inside a test case for the "list command" that says something like, "List - list all the users on a team", when I refactor the List.java class to something like UserListCommand.java, the expression inside the string also changes to "UserListCommand - list all the users on a team"
This is SOOO annoying! And like I said, Google is useless when you cannot even think of the right keywords to use.
Has anyone else had this problem and solved it?
Thanks in advance.
Eclipse calls this updating textual occurrences in comments and strings. I sometimes turn this on so javadoc gets updated correctly if I didn't properly link it. But it can be a pain because it sometimes replaces substrings that match.
I've only seen this when renaming classes or interfaces (methods don't seem to do this, at least not for me),
You need to open the Rename Dialog to stop eclipse from updating textual occurrences in comments and strings:
Highlight the type you want to rename, then either:
press Shift+Alt+R
Right click, then go to refactor->rename.. then instead of typing the new name, there should now be a yellow context popup menu under the class name to be changed which says "Enter new name, press Enter to refactor", notice that there is a down arrow to expand the menu. If you press that instead of enter a new name a new drop down menu appears, select Open Rename Dialog...
Once the Rename Dialog is open:
uncheck "update textual occurences in comments and strings (forces preview)" and "Update fully qualified names in non-Java text files (forces preview)"
Hope that helps
In Eclipse (HELIOS) there is an option to scan all source code and search for task tags such as "TODO", "FIXME" etc. The result is then shown in a fine list.
One can access this list by: Windows->Show View->Tasks.
However, it also scans resources directory and libraries, whose task tags are not of my interest. How can I filter Task Tags searching by directory exclusion filter?
10x
It is possible.
Open the Tasks view. Then press icon with the down arrow (top right corner of the window, next to minimise button) and press "Configure Contents..."
Either add new configuration or modify TODOs
In the Scope section select "On working set:" and press button "Select..." to create a new workspace
Create a new workspace with only selected folders that you want to include
Also there is the way I work around that limitation: Define your own tags, i.e. by adding your name or some shortcut and use the task-list's filter function to ignore the rest.
In the preferences you can define your own TODO Tags (for highlighting purposes etc.) or you can leave it with TODO, FIXME, XXX..
Also in the preferences you can redefine the default Comments like "TODO: Auto-generated something" to "TODO Nir: Auto..."
In the Task List you can then filter for exactly those tags.
Cheers,
Rob
Unfortunately, the answer is that this is not currently possible. You can configure the set of task keywords on a per-project basis along with the priority of each, but no more than that.