How to create a scratch pad in Eclipse? - eclipse

This is a very simple question. I often find myself wanting to create a scratch pad/buffer in Eclipse in which I need to copy-paste something or write some notes without creating a file for it.
For example, when I am working in Vim, I can create a new buffer with :new (actually a shortcut key mapped to :new) and get going. Or in most other editors, I can just press Ctrl+N to create a new buffer.
Is this possible in Eclipse?

Maybe this could do:
"File" -> "New" -> "Other" -> "General" -> "Untitled text file"

Related

How do I see all current file associations?

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.

Intellij IDEA: Make refactor > Rename not select the whole word

When I press my shortcut to rename a variable (precisely it's the "Main menu" > "Refactor" > "Rename..." shortcut), the entire word is selected.
Is it possible to change the behavior so that simply the refactoring is activated and the cursor stays in position (it already does, this is fine) and that I can directly add or remove a character?
Right now, if I have a variable "myVarible" and I put my cursor between "i" and "b" to add the "a", press the shortcut, and type an "a", my entire variable becomes an "a", as the entire word was selected by the shortcut.
In Eclipse this seems to be the default behavior already, and I liked it much better. How can I change this in Intellij?
You can do this by going to Settings -> General -> Refactoring and just deselect "Preselect old name" or just type Refactor in search box in settings so it will automatically go on above menu.
From IntelliJ 2018.2.6, the checkbox to disable is still "Preselect old name".
That is located in :
"Settings" menu
-> "Editor" section
-> "General" subsection
-> "Refactorings" part
You can also just enter "refactorings" in the search box to find it.
Aaaand it moved again!
It's probably the best to just search for Refactorings or Preselect old name, as it might move again in the future.
In my version 2020.1.2 it is under
Settings -> Editor -> Code Editing -> Refactoring
It has changed name since the other answers, in 2021.2.3, It's still under Settings -> Editor -> Code Editing -> Refactorings however it's now named Preselect current symbol name for Rename refactoring.

Update eclipse editor references

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);

Sublime text 2 - find file by class name in Zend Framework

When you press Ctrl+p Sublime will open popup when you can easily find the file. Sublime auto detect the file location in both situation when you press / or space between file path parts.
In Zend Framework all classes has name within follow template: Namespace_Module_Other_Part_Of_Class_Location, how can I make Sublime understand the _ as a path separator when I press Ctrl+p and copy past the class name there?
So the above class should be recognized on location: Project/Namespace/Module/Other/Part/Of/Class/Location.php
I'm still looking for the solution of it. Even if the file search is hard-coded in Sublime 3, and you have a workaround to make it works, maybe to write some plugin? you are welcome.
Thank you.
You can do this with a simple plugin and key binding. Select Tools -> New Plugin... and replace the contents with the following:
import sublime
import sublime_plugin
class UnderscoreToSpaceCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command('copy')
clipboard = sublime.get_clipboard()
clipboard = clipboard.replace('_', ' ')
sublime.set_clipboard(clipboard)
Save the file as Packages/User/underscore_to_space.py where Packages is the folder opened when clicking on Preferences -> Browse Packages....
Next, create a custom key binding for the command. Select Preferences -> Key Bindings-User and add the following:
{ "keys": ["ctrl+shift+c"], "command": "underscore_to_space" }
If the file is empty when you open it, surround the above line with square brackets [ ]. Save the file (it will automatically save to the correct location), and you're all set.
Now, all you need to do is select the text you want to convert, and hit CtrlShiftC. This will copy the text to the clipboard, replace the underscores with spaces, and put the modified text back in the clipboard. You can now hit CtrlP to open Goto Anything... and paste in the modified text with CtrlV.
If you prefer to have the underscores replaces with forward slashes /, just change the clipboard.replace() arguments from ('_', ' ') to ('_', '/').
To get to the class definition you are looking for there exist several plugins doing "code intelligence". The plugins are language specific.
The most popular is SublimeCodeIntel which provides Jump to symbol definition functionality. SublimeCodeIntel claims to do this for PHP too. However, who to setup this for your project should be another question.
Some more options for possible source code static analysis in Sublime Text 2 in this blog post:

How to remove the lock in file association in eclipse

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