Let\'s say you have some lines that look like this
1 int some_function() {
2 int x = 3; // Some silly comment
And so on. The indentation i
I needed to halve the amount of spaces on indentation. That is, if indentation was 4 spaces, I needed to change it to 2 spaces. I couldn't come up with a regex. But, thankfully, someone else did:
//search for
^( +)\1
//replace with (or \1, in some programs, like geany)
$1
From source: "^( +)\1
means "any nonzero-length sequence of spaces at the start of the line, followed by the same sequence of spaces. The \1
in the pattern, and the $1
in the replacement, are both back-references to the initial sequence of spaces. Result: indentation halved."