Text editor function to indent multiple lines at once
Asked Answered
R

3

33

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?

Rheumatic answered 18/1, 2013 at 16:34 Comment(2)
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.)Spool
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 ...Wharf
U
29

You can do:

  1. Command + ]: to tab right
  2. Command + Shift + ]: to space right
  3. Command + Shift + [: to move left
Udale answered 18/1, 2013 at 16:36 Comment(1)
Answer is correct. However, makers of BBedit have never used a keyboard which has no keys for [ or ]. All other editors indent by tab. Why doesn't BBedit?Erland
N
61

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

Nikolas answered 14/11, 2013 at 16:39 Comment(4)
Thanks, this is what I was looking for. Now its just like gedit.Dawkins
This should be the right answer! Worked perfectly, thanks!Nitaniter
Where is "Preferences"? In menu "File"? In menu "Edit"? Somewhere else?Pluck
@PeterMortensen under BBEdit or shortcut: command + ,Fort
U
29

You can do:

  1. Command + ]: to tab right
  2. Command + Shift + ]: to space right
  3. Command + Shift + [: to move left
Udale answered 18/1, 2013 at 16:36 Comment(1)
Answer is correct. However, makers of BBedit have never used a keyboard which has no keys for [ or ]. All other editors indent by tab. Why doesn't BBedit?Erland
F
16

Command - Close Bracket (]) to tab right;

Command Shift Close Bracket to space right;

Same with Open Bracket ([) to move left

Fullblooded answered 7/3, 2013 at 0:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.