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

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 - meta.stackexchange.com/questions/84718/… – YOU Apr 18 '11 at 7:44
Also see: meta.stackexchange.com/questions/56326/… – 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

1 Answer 1

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 .