136
votes

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.

3
I personally open up another code editor like VS Code to do just this.Pramesh Bajracharya
@PrameshBajracharya what do you mean ? An external app or an extension ?Entretoize

3 Answers

200
votes

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.

enter image description here

Find for binding in text box surrounded by red box.

26
votes

On OS X, the key combination for multi-line edits in Eclipse (or STS) is option/alt+command+A

5
votes

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.