Parentheses over selected words in Eclipse - eclipse

A few days back I felt this question to be dumb and dint post it here, but after even after searching a lot I dint find a proper solution.
For those of you who used TextEdit (on Mac), they will perfectly know what I am talking about.
While coding I just want to put quotes or parentheses over a word or a line.To do this I'll have to move back to the starting of the word, open the quote and then go to the ending of the word and close it.
Is there a plugin or so in eclipse where I can just surround the current selection with quotes or parenthesis ?? I am not talking about quick fix (Ctrl + 1). It can be used for much complex templates.

You can do that with a custom template, so for example if you want to create this template for java, you can do :
Preferences ---> Java ---> Templates
Create a new template and call it quote, then type this as pattern :
"${word_selection}"${cursor}
Save it and Apply.
After that you can use that template selecting the text you want to quote then press CTRL + SPACE and then chose quote.
Same thing for parenthesis :
(${word_selection})${cursor}

Related

Replacing a string in Rubymine with a string with newlines

I want to use the Search and Replace dialogue in Rubymine, or something similar to replace something like "Scenario:" with "#Desktop\nScenario"
I'm trying to replace every instance of Scenario: in a large Cucumber test suite with
#desktop
Scenario:
Any best ways to do this?
Update:
Thanks to #ryan2johnson9 comment, I realise there's now an easier option (tested on 2017.3).
By clicking on the "New Line" (or using the shortcut Ctrl+Shift+Enter / Alt+Enter), the input becomes multilines.
Original Answer
In the search and replace box, if you tick the "Regex" option you can do:
Search: "Scenario:"
Replace by: "#desktop\nScenario:"
The only trick is to tick the "Regex" option :)
Rubymine has macros (http://www.jetbrains.com/ruby/webhelp/binding-macros-with-keyboard-shortcuts.html) but I dont think they are powerful enough for this example.
It's possible that you could solve it with some elaborate feature hidden inside Rubymine, but I think it would be a lot easier to do this with a tool like perl/sed from the Terminal. If you are using Windows I assume you could search the net and find a text search/replace tool that fits your need.
In OSX I there are a bunch of Text Substitutions app too.
I would go that route since Rubymines macro tool isnt up to the task.
Here's a cheap and sleazy alternative:
Copy a newline character from between two empty lines in the file being edited. Temporarily add two empty lines if you don't have any.
Set up search/replace and enter the string you want to replace into the search text input box.
Paste the newline you just copied into the replacement text box plus whatever other text you want. You will be able to see the height of the replacement text input box grow vertically by one line due to the newline.
Perform the search/replace.
For this, the use of the Rubymine regex is optional.

Sublime Text 2 how to wrap selection with quotes/auto-pairing

I just switched from Textmate 2 to Sublime Text 2. I figured that typing single quotes or brackets would automatically generate a second quote or bracket with the cursor in between ("auto-pairing" is what they call it, Textmate2 does this by default) but this isn't happening.
I see that in the preferences->settings-Default there is some JSON configuration that would seem to be doing what I need but this is not the case. I haven't changed any of this default configuration.
Could someone help me add to my preferences->settings-User the configuration I need to enable auto-pairing for all the common tags, i.e., "'{[(?
Right now I'm working on a client's laptop and running Sublime Text 2 portable version from my flash drive. No additional packages installed, default settings. Everything works as expected:
When I type a single or double quote, brackets, square or curly brackets it adds a closing one and puts cursor in the middle.
When I select smth and press any of mentioned above keys it surrounds selection with pair of appropriate quotes or brackets.
Check your Settings>Default, look for this:
// Controls auto pairing of quotes, brackets etc
"auto_match_enabled": true,
It's near line 89 or so.
Not a direct answer to your question..but I have installed a few plugins in ST2 and auto-pairing works fine.
I am not sure which plugin is responsible for it. Let me know if you would like me to share the list of plugins.

Is there a good "find all" function in Eclipse?

I have been using Eclipse for R and C++. So far I have not been able to find a reliable "find all" function. It seems to be an easy concept, I search for a string such as "rows" and the function should return all occurences of it within the that I currently have open. (Even if it's in all files in my owrkspace, that's fine too.)
However, I have either not understood how to use the "search" functions correctly or they are very buggy.
So my question is how do I search for all occurences of a string in a file in Eclpise?
Adobe Dreamweaver, for example, has been able to do this for years.(Although it's completely unrelated to R and C++)
I would like to view a list of all occurences and then be able to click on a specific occurence to go to it.
After opening Eclipse, (corresponding to a workspace), Press "CTRL + H" anywhere and you can search anything
like java files that contain specific "keywords".
all occurences within a java file.
plugins names etc
Just type "rows" or whatever the search term is somewhere in text, select it (so that it becomes highlighted) then press "Alt+Ctrl+g". This will perform a global search for that term, pretty handy.

Hungry Backspace in Eclipse?

In some editors there exist plugins implementing a feature called "hungry backspace" or "hungry delete".
If this mode is active in a text editor then one hit to the backspace key will automatically delete all whitespace chars backwards from the current cursor position up to the first non-whitespace character.
For example, this feature exists for Emacs and IntelliJ IDEA.
Does anyone know if it is also available in Eclipse?
Alt-Del is probably as close as you're going to get without writing a plugin yourself. Others have asked for this feature (coming from intelliJ) but so far it doesn't exist, or it's not published.
-Adam
CTRL-backspace is pretty close too: delete previous word:
function(); (4 spaces)
+ CTRL-BACKSPACE gives:
function
Other than that, AnyEdit plugin can convert trailing spaces into tabs (but also into "", effectively removing them)
Ctrl+Shift+Left, Backspace always works for me. works in notepad, web browsers, everywhere.
Stick to the standards :)
In SciTE, and Eclipse (3.4), Ctrl+Shift+Del with the caret after the last visible character will delete these spaces. Ie. it deletes from caret to end of line.
Actually, in SciTE I don't need to do that, since I have set it up to automatically remove these trailing spaces when saving.
Note: In Preferences > General > Keys, there is a Remove Trailing Whitespace binding (without key assignment by default) which seems to apply to File.
From eclipse Windows menu/Preferences
Search for Keys and filter to "Delete Previous Word"and Bind it to the Ctrl+Backspace

Is there an Eclipse command to surround the current selection with parentheses?

Is there an Eclipse command to surround the current selection with parentheses?
Creating a template is a decent workaround; it doesn't work with the "Surround With" functionality, because I want to parenthesize an expression, not an entire line, and that requires ${word_selection} rather than ${line_selection}.
Is there a way that I can bind a keyboard shortcut to this particular template? Ctrl-space Ctrl-space arrow arrow arrow isn't as slick as I'd hoped for.
Maybe not the correct answer, but at least a workaround:
define a Java template with the name "parenthesis" (or "pa") with the following :
(${word_selection})${cursor}
once the word is selected, ctrl-space + p + use the arrow keys to select the template
I used this technique for boxing primary types in JDK 1.4.2 and it saves quite a lot of typing.
Easy, Window->Prefs, then select Java->Editor->Templates
Create a new template with : (${line_selection}${cursor})
The "line_selection" means you have to select more than one line.
You can try creating another one with "word_selection", too.
Then, select text, right click, Surround With... and choose your new template.