28

I want to make my code more organized. So, whenever I copy a function from my functions.php file and paste it in a class, I need to indent each line of the function one or more times so that it's easier to read and looks nice. Some of my functions are nothing more than huge switch statements and indenting each and every line once has proven to be time consuming and tedious.

Are there any functions in TextWrangler that lets users indent a highlighted chunk of code at once?

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Lance
  • 4,488
  • 16
  • 49
  • 85
  • Maybe a large cause of the issue is an approach that requires the code duplication and complicated switch structures .. (It's a valid tooling question, but it might be caused by a situation that can be avoided.) – user2864740 Jan 04 '15 at 17:49
  • From your comment on Red2678's answer, it sounds like you wanted a function that indents each line of the selected chunk independently to the right indentation, rather than a function that changes the indentation of every line in the chunk by the same amount. Is that right? That's what I'm looking for ... – LarsH Jan 08 '15 at 14:32

3 Answers3

54

You can go to Preferences > Keyboard and then select "Allow Tab key to indent text blocks".

Bruno
  • 589
  • 1
  • 4
  • 4
26

You can do:

  1. Command + ]: to tab right
  2. Command + Shift + ]: to space right
  3. Command + Shift + [: to move left
Red2678
  • 3,063
  • 2
  • 26
  • 40
15

Command - Close Bracket (]) to tab right;

Command Shift Close Bracket to space right;

Same with Open Bracket ([) to move left

jcaponi
  • 373
  • 2
  • 10