blahblah
blahblah

Reputation: 1251

refactoring multiple variable names intellij

Is there any way for Intellij to refactor the code consisting of multiple copy-pasted lines like this one:

Comment a1 = new Comment(1,null);
Comment a1 = new Comment(1,null);
Comment a1 = new Comment(1,null);
... and
.. so
. on

into

Comment a1 = new Comment(1,null);
Comment a2 = new Comment(1,null);
Comment a3 = new Comment(1,null);
... and
.. so
. on

Upvotes: 1

Views: 710

Answers (1)

Meo
Meo

Reputation: 12531

The closest thing to do that would be Shifter plugin. It can increment the number in a variable under the caret (and more in the future).

Or String Manipulation plugin which can duplicate and increment numbers inside of the selected text, making:

Comment a1 = new Comment(1, null);

into

Comment a1 = new Comment(1, null);
Comment a2 = new Comment(2, null);

or just increment all numbers in a selection, or on a line with a caret.

Upvotes: 2

Related Questions