What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

Often I see this.

          foreach ($langs as $lang => $val){
            if ($val === '') $langs[$lang] = 1;
          }

This annoys me and often creates unnecessary horizontal scrolling, so I tend to fix it by removing the leading spaces. Resulting in that.

foreach ($langs as $lang => $val){
  if ($val === '') $langs[$lang] = 1;
}

After doing it a lot, I got bored, as the only way is deleting the spaces manually, separately on each line.
I did check out this topic and gave this tool a shot, but it won't remove the annoying spaces.

May I therefore make a proposal:
When Ctrl+K Ctrl+Shift+K is pressed, check if certain number of spaces can be safely removed from the beginning of each line. If so, remove that (same) number of spaces from each line, resulting in the least-indented lines being exactly 4 spaces to the right.

Relative indentation is obviously not affected, so the code remains formatted as the author wanted it, but shifted to the left as a whole.

And may Ctrl+K retain its default behaviour, because there's Fortran 77 as dmckee noted.

share|improve this question
    
possible duplicate of Automatic code reindent button –  Cody Gray May 31 '11 at 14:06
    
ctrl+shift+K??? I've always put the spaces there manually. I feel so stupid. –  user157130 May 31 '11 at 14:10
    
@Tim Just Ctrl+K. I'm trying to suggest Ctrl+Shift+K as the "also remove leading spaces" mode. –  GSerg May 31 '11 at 14:50

2 Answers 2

Column formatted Fortran. 'nuff said.

share|improve this answer
    
Riiight... Didn't know that. See the edit. –  GSerg May 31 '11 at 1:08

Highlight the code block, and press Ctrl+K. Each time you press it, one level of indentation is removed from the entire block. This is a very quick and easy way to remove superfluous indentation.

Problem solved. No need for a new feature.

share|improve this answer
    
Well, yes, that sort of helps, but it removes spaces 4 at a time, so it can still leave 1-3 unwanted spaces. –  GSerg May 31 '11 at 14:49
    
@GSerg: I try not to let 1 or 2 spaces ruin my day. Having the code indented by less than 4 spaces isn't really a problem. Some people even do it intentionally to set it off from the body text even more. –  Cody Gray May 31 '11 at 23:03
1  
This doesn't seem to work with tabs? –  Steven Jeuris Oct 28 '11 at 21:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .