views:

153

answers:

4

I've seen this done in TextMate and I was wondering if there's a way to do it in IDEA.

Say I have the following code:

 leaseLabel = "Lease";
 leaseLabelPlural = "Leases";
 portfolioLabel = "Portfolio";
 portfolioLabelPlural = "Portfolios";
 buildingLabel = "Building";

What is the best way to append '+ "foo"' to every line? Column mode won't work since the lines are not correctly aligned on the right side... unless there is an easy way to right justify the text :P

Thx in advance!!

+1  A: 

You may use regular expressions with match variables. Basically, match your line with

([^;]+);

and replace with

$1 + "foo";

Or something similar.

Yuval F
+3  A: 

I just use the macros for this sort of thing. I start recording the macro, do it once, then play back the macro on each line I want to modify. You'd be amazed at how fancy you can get with the macro record/playback feature.

Chris Kessel
Throw away macros can be very handy for do these sorts of changes. How you descibe it is exactly what I would do if I was making these changes inside the Zeus editor.
jussij
+1 - this is the "right" answer
joeslice
If the lines are all grouped together like that, then record the macro to also move the cursor to the next line, then you just have to start running the macro on the first line and repeat however many times you want.
weiji
+2  A: 

In this case you can also just select the piece of code in which you want to do this and perform a replace on it. Replace:

";

with:

" + "foo";

So in case you didn't know: If you have text selected while you perform a replace (Ctrl+R or Cmd+R) it will only apply to the selected piece of text.

Tom van Zummeren
A: 

does there have a easy way to reverse the String ?

make leaseLabel = "Lease"; ------> ;"esaeL" = lebeLeseal

Cong De Peng
You shouldn't post new questions as answers. Better use the "Ask Question" button in the top right of the page.
sth
...and you could delete this post, since it doesn't answer this question here
sth