Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 153 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Sometimes, when I copy and paste code from my editor to the question box, the indent level is too much; I think there should be buttons to move the indent level left or right without having to unindent the code in a text editor first.

share|improve this question
2  
+1. If every line pasted contains 4+ spaces or 2+ tabs, it should be safe to assume that it is code, and to rewrite the whitespace accordingly. – Won't Dec 5 '11 at 15:26
    
@ಠ_ಠWon't see below. – amanaP lanaC A nalP A naM A Dec 5 '11 at 15:27
up vote 0 down vote accepted

You can just highlight and press Ctrl + K

For example:

    echo json_encode(array(
            'success' => $s,
            'fee_id' => $e,
            'id' => $i,
            'randomness' => array($e, $_POST, $query),
            'error' => $error,
        ));

    exit();

Ctrl + K

echo json_encode(array(
        'success' => $s,
        'fee_id' => $e,
        'id' => $i,
        'randomness' => array($e, $_POST, $query),
        'error' => $error,
    ));

exit();

Ctrl + K

echo json_encode(array( 'success' => $s, 'fee_id' => $e, 'id' => $i, 'randomness' => array($e, $_POST, $query), 'error' => $error, )); exit();

Well thats gibberish...

And when you press Ctrl + K again it should go back to the 2nd example above of being formatted nicely :-)

share|improve this answer
2  
This doesn't always work as expeected. Also, not pressing ctrl-k is always better than pressing it ten times to fix your indents. – Won't Dec 5 '11 at 15:33
    
@Wont The OP specifically asked for buttons to do it, not a magic auto-indenter like you seem to want – Michael Mrozek Dec 5 '11 at 16:14

You must log in to answer this question.

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