Shortcut to put hyphens around selection in Eclipse - eclipse

Is there a quick and easy way to transform a selected text into "text". If you just press Shift + 2 on selected text, the text will be replaced by " and not enclosed ".
Same question for different IDE (Visual Studio)
Is there a way to put double quotes around selected text?

Related

VSCode "Expand selection" in plain text files

In code files, when I expand selection, brackets, quotes, and spaces are used to delimit "levels" of expansion.
However, when I'm working in plain text, expand selection ignores brackets and goes from selecting one word to then selecting a whole line.
Is there any way to have expand selection respect brackets and quotes in plain text files?

How to add quotation marks around selected text in Eclipse

Countless times i have needed to put a quotation marks around text during programming. I remember awhile ago that i have seen someone selecting text and simply do magic with the keyboard shortcuts and putting quotation marks around it. How to do so?
In eclipse
1. Window -> Preferences -> Java -> Editor -> Templates
2. Click on "New"
3. Type "quote" for name (you can name it whatever you want)
4. In the pattern box, enter "${word_selection}"${cursor}
5. Click ok
6. Click apply and close preferences
7. Select the string you want quoted, press CTRL + <space> and type quote

Different Quotation Marks

A quotation mark placed by the Eclipse editor works just fine in an XML file. Yet if I edit the XML in Microsoft Word and type in a new quotation mark and then place the XML back into Eclipse I get errors. The two quotation marks look different: one looks normal, while the one from Word looks like an italic version. When I replace the Word Quotation marks with the Eclipse marks the errors go away. I'm sure its different ascii codes. What's going on here?
Word is inserting smart quotes (that is the technical term for them). The ones that word puts are opening and closing ones. Word is created as a document editor, not a code editor. It puts in corrections to make your documents look better, not preserve language syntax. If you still want to use word as a code editor, you can disable smart quotes (in Word 2007 it is under Options > Proofing > AutoCorrect Options... > AutoFormat Tab > "Straight quotes" with "smart quotes")
Microsoft Word automatically changes quotation marks into curly quotation marks (left and right) as you type. The curly ones are not the same ACSII character as the normal quotation mark.
In Word 2003, there's a setting in AutoCorrect options in the AutoFormat As You Type tab that says replace "straight quotes with smart quotes", so you can disable this feature. I don't know where to find this setting in later versions of Word.

How to do multiple line editing?

I want to edit multiple lines in eclipse, but I can't find any short cut or Plugin. In Geany I just press ctrl+alt+up/down I can add / edit multiple lines.
Maybe this example can explain what I mean:
var text = "myname";
var addr = "myaddr";
var age = "myage";
I want to edit text above into:
var my_text = "myname";
var my_addr = "myaddr";
var my_age = "myage";
The text above is just a simple example, but sometimes I have many lines of words that I have to edit its prefix.
Press alt + shift + A to Toggle block selection (Toggle block / column selection in the current text editor), this will let you write vertically in eclipse, then you can easily do this.
Go to Window->Preferences.
Find for binding in text box surrounded by red box.
On OS X, the key combination for multi-line edits in Eclipse (or STS) is option/alt+command+A
You can try the following plugin,
https://github.com/caspark/eclipse-multicursor/releases
With this multiple occurrence of same text can be selected and edited. This is similar to multi select functionality available in editors like Sublime and Visual studio code.
The Eclipse 4.24 (June 15 2022) will integrate it (See https://bugs.eclipse.org/bugs/show_bug.cgi?id=576377):
Multi selection down relative to anchor selection (e.g. Ctrl-Alt-J)
Multi selection up relative to anchor selection (e.g. Alt-J)
End multi-selection (e.g. ESC)
Add all matches to multi-selection (e.g. Ctrl-Shift-Alt-J)
Multi caret up (e.g. Ctrl-Alt-Shift-Up)
Multi caret down (e.g. Ctrl-Alt-Shift-Down)
Thanks to eclipse contributor !
The Eclipse 4.22 (Q4 2021) equivalent of Geany would Alt+Click on the lines you want to edit in one go.
Eclipse now supports
Multiple text selection
Support for multiple selection has been added to Text Editors.
Multi selections allow most edit operations (text replacement or insertion, extend selection to next word or to next line, copy/paste...) to apply simultaneously on all ranges.
Multiple strategies are available to enable multi-selections:
Turn a block selection into a multi-selection using the To multi-selection command,
Add a caret with Alt+Click,
Use the new Select All button on the Find/Replace dialog.
So check if this would work in your case.
I know this is an old post, but I still want to share my way of multi select and editing. However this way is restricted to only the same variables across the file. Simply highlight the variable to edit, right click, choose Refactor->Rename. Then edit the variable and it will also edit the same variables across the file. Hope it helps..:)
Press key - { Alt + Shift + A } You will see A [+] symbol in IDE then use this symbol as drag

Parentheses over selected words in 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}