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

I love StackExchange. The only frustration is copying and pasting code over or writing code in answers and posts. For example, to write the following block of Python:

1. def hello(self):
2.     if (self.DEBUG == True):
3.         print "Hello World!"

For line 1, I had to type SpaceSpaceSpaceSpace.
For line 2, I had to type SpaceSpaceSpaceSpaceSpaceSpaceSpaceSpace.
For line 3, I had to type SpaceSpaceSpaceSpaceSpaceSpaceSpaceSpaceSpaceSpaceSpaceSpace.

It'd be awesome if there'd be a way to enable Tab on an opt in basis for indenting code.

share|improve this question
    
It's even more annoying when you're trying to do multi level indentation and Ctrl-K kills the existing indentation rather than adding more. –  Flexo Dec 19 '11 at 23:34
    
What is this Ctrl+K of which you speak? –  Naftuli Tzvi Kay Dec 19 '11 at 23:36
2  
Shortcut for code markup - the same a clicking the {} button on the toolbar. –  Flexo Dec 19 '11 at 23:37
    
And the beauty is that this is so easy. –  Purag Dec 19 '11 at 23:54

2 Answers 2

I would be wary of capturing Tab in the editor only because not everyone will necessarily agree on the same number of spaces per tab (for instance, should Ruby code treat tabs as two spaces or four?).

Likewise, although I would personally love to have an autoindent feature, the same caveat with respect to the number of spaces per tab still applies.

share|improve this answer
    
Well, for SE's implementation of Markdown at least, a tab is four spaces. Just sayin'. –  Naftuli Tzvi Kay Dec 20 '11 at 1:39
    
@TKKocheran Ah, true enough. –  Chris Frederick Dec 20 '11 at 1:42
    
Also, they should flat out swap out the editor for vim, but that's for another feature request. –  Naftuli Tzvi Kay Dec 20 '11 at 1:43

Wouldn't there be some sort of accessibility concerns if you started capturing Tab in the editor? Keyboard nav would be broken. I suppose that's why it has to be opt-in.

I'm definitely for this. To go one step further, you could build in a keyboard shortcut to autoindent the selected text. That way you might not even need to worry about Tab, but people could still easily indent their code. It'd even create a quick cleanup procedure for things like new user/low quality posts: edit, autoindent, save.

share|improve this answer
    
Opt-in is exactly for the reasons you describe. For those of us who don't need accessibility at the moment and want to tweak things to make input a lot faster, this would be great. –  Naftuli Tzvi Kay Dec 20 '11 at 0:15
2  
And yes, autoindent would be awesome. –  Naftuli Tzvi Kay Dec 20 '11 at 0:16

You must log in to answer this question.

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