Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 157 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

Most of the time, I paste example code into my questions/answers, but for very short snippets I also type it directly into the field in the browser. For those times, it would be really nice to have a simple automatic indentation of the code. Nothing fancy that would analyse the presence of opening or closing braces, but some simple mechanism like, e.g., automatically reinsert n spaces/tabs after I type Return if the previous line also began with n spaces or tabs.

share|improve this question
related -… – YOU Apr 18 '11 at 7:44
Also see:… – Cody Gray Apr 18 '11 at 8:40
I'm not asking for full-blown autoindent (which clearly is a huge effort) — just for the reinsertion of whatever my current indentation is on newlines. – Jean-Philippe Pellet Apr 18 '11 at 8:48

Shift-Return already does this, if you can get used to that...

(Or, as a workaround: just type without indenting, then select the whole block, and use the code button or hit Ctrl-K.)

share|improve this answer
Shift-Return only inserts 4 spaces. I would like a system that inserts as many spaces as there was on the line before. The workaround is only partially helpful, because if I'm writing a multi-line body of an if, I also don't want to indent each line with two/four spaces again. – Jean-Philippe Pellet Apr 18 '11 at 8:05
Maybe not everyone likes to have code indented that way. It seems like a copy and paste from your favorite editor should take care of that. – this.josh Apr 22 '11 at 19:35

You must log in to answer this question.

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