Reputation: 19612
I want to add two spaces to the beginning of each line in my selection. Every sane editor I've ever used let me do this using the equivalent of s/^/ /g (that's two spaces but SE collapses it into one). In Eclipse (Kepler), I go to Edit->Find/Replace, type '^' into the 'Find:' box, ' ' in the "Replace with" box, select 'Selected lines' under 'Scope', and check the 'Regular expressions' check box. When I click 'Replace All', nothing happens, except that the Find/Replace dialog says 'String Not Found' at the bottom. What incantation do I have to use to please Eclipse in this case?
Upvotes: 1
Views: 3335
Reputation: 1373
^ and $ are zero width anchors. You need to put some content with them. In this case you can capture a group and add spaces in front as follows:
Find: ^(.*)$
Replace: $1
(Two spaces followed by $1)
Upvotes: 2