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.

Does anyone else have problems with the editor? I may be doing something incredibly stupid but I find that whenever I use tab I tab out of the box. Which is obviously irritating if your trying to add a code sample.

So it would be quite cool if tab inside the main text box could be used for indenting. I know this would mess up people who like to navigate the form using tab but the content for a question is often large enough to justify it IMO.

What are your thoughts? Any other issues you have with the editor?

share|improve this question
31  
I find the lack of intellisense when entering code frustrating too ;) –  ChrisF Jun 29 '09 at 9:14
5  
I wish that tabs were disallowed completely, but that's just me. (They show up as 8 spaces on IE7, which often means extra scrollbars.) –  mmyers Jun 29 '09 at 18:03
14  
@mmyers: They could be converted to 4 spaces by SO. –  musicfreak Jun 29 '09 at 19:12
9  
some of us actually use the tab key for navigation... since that's how every other data entry form on the web works... –  Kip Jun 30 '09 at 13:57
    
@mmyers, @musicfreak: actually tabs are converted to spaces when displaying the code, it is only in the textarea when creating/editing the text that actual tabs are displayed. –  Kip Jun 30 '09 at 16:11
    
I doubt, Jeff will do that. He belongs to the spaces front: codinghorror.com/blog/archives/001254.html –  Ladybug Killer Jul 22 '09 at 15:50
7  
I'm not gonna chance getting downvoted by you haters, so I'm going to chime in with the other two folks in negative numbers on this question: don't change tab behavior!! Instead, consider Jon Skeet's or Brad Gilbert's option; preferably both. Do not break web standards for a little comfort. I'm a big fan of the editor, personally, and I frequently find myself wondering why Control-K, Control-L, Control-O, and Control-U won't work when I post on forums or blogs. Make the indenting follow that paradigm, rather than hacking the tab key. –  Randolpho Jul 22 '09 at 17:33
    
Haters is pretty harsh.. –  Damien Jul 22 '09 at 17:48
4  
Yeah, the tab button drives me nuts almost every time I post. I know its my own fault but I am so used to pressing tab to indent that I don't even think about it til its too late. Have even managed to submit incomplete answers by pressing tab then enter. These days I try to avoid the editor completely and just use my notepad replacement instead and copy the text in. Still manage to forget sometimes tho... –  Addsy Jan 11 '10 at 16:47
1  
+1 @Randolpho for not wanting to change the behavior... except, -1 @Randolpho for using a comment solely to avoid downvotes. –  Pops Sep 25 '10 at 22:03
    
I would also find this useful on occasion, although... Not as useful in general as being able to tab out from the edit field. Making this apply only when the cursor was in a code section would be an interesting exercise (for someone handy with the userscripts ;-))... –  Shog9 Jun 17 '12 at 21:21
    
Damien, could you please generalise the body of the question so that it deals with only one topic, i.e asking for suggestions to improve the editor? Then you could post your tab key suggestion as an answer. –  Asad Jan 6 '13 at 1:23

18 Answers 18

One very simple one - when writing code, when we hit "enter" it would be really nice if it went to the same indent, i.e.

void Foo()
{
   if (foo) <- I'm about to hit enter here
 > | <- I would like the cursor to be positioned here

Another request - the Ctrl-K shortcut indents the code if any of it is at the first column, but outdents otherwise. It would be nice to have a shortcut to always indent, so it's easy to indent a whole block of code. (Usually I add an extra line with a character at the start, then select the whole block including the new line, hit Ctrl-K and then remove the extra line, but that's a pain.)

Oh, and finally: a shortcut key to display all the shortcuts as an overlay, like Google Reader does. (Press "?" in Google Reader to see what I mean.)

share|improve this answer
25  
+1 for auto-indent. –  mmyers Jun 29 '09 at 18:01
4  
What about Ctrl+] or Ctrl+> for indent? I have found many editors that support at least one of those. –  Brad Gilbert Jul 23 '09 at 0:20
    
Additionally buttons for an important thing like indent/outdent would be nice, especially for newer users who'd probably mainly look at the editing buttons and not look up short cuts. –  Georg Fritzsche Dec 4 '09 at 5:33
    
yep, liking the auto-indent idea –  Addsy Jan 11 '10 at 16:47
2  
Never mind the editor - have a +1 for that Google Reader tip. –  razlebe Jan 12 '12 at 12:24
    
so, let's do this. –  solvingPuzzles Oct 14 '12 at 5:03
    
I strongly agree that once you’ve gotten use to :set autoindent in vi, using a code editor that doesn’t have it is super-frustrating to the point that it no longer seems like a real code editor. I’ve given up trying to enter code in the text boxes; it is far too primitive. So I end up editing the code to insert in a separate vi window, and then use murine snarf-n-barf to transfer the code once done. It’s not for everyone, but at least that way I get a proper code editor without forcing SO to code it up in their text widgets. –  tchrist Jan 6 '13 at 1:32
    
Someone has worked very hard on a simply javascript implementation here: pallieter.org/Projects/insertTab –  hitautodestruct Jan 17 '13 at 12:11
    
Everytime I type in code I think that this is missing. What might be the reason it is not implemented yet? Also, see the dedicated thread here: meta.stackexchange.com/questions/146236/… –  usr Jul 24 '13 at 13:13

These shortcuts are found in many / most editors. These would be very useful for putting a code block inside of a list item, for example

  • Ctrl + ] : Indent by 4 spaces
  • Ctrl + > or . : Indent by 4 spaces
  • Ctrl + [ : De-indent by 4 spaces
  • Ctrl + < or , : De-indent by 4 spaces

Other potentially useful keyboard shortcuts.

  • Ctrl + & or 7 : Replace < with &lt; > with &gt; etc (HTML escape special characters)
  • Ctrl + ! or 1 : Replace selected text with the final html code
    This would be useful when you want a code sample in a blockquote.

It should also be possible to have customized combos that are attached to an account.
Since there are many different variations of keyboards, it would be short-sighted to have only have a hard-coded set of available combos.

share|improve this answer
    
I can't +1 this one enough. Great ideas. –  Randolpho Jul 22 '09 at 17:28
    
Hm.. that could actually work! Auto-indent idea is likely to break pasting, this should work fine as it doesn't screw with default behaviour, just a few extra (otherwise unused) keyboard shortcuts.. –  dbr Sep 4 '09 at 12:46
1  
Nice idea in theory, but there's no way I'm going to learn a three-key combination instead of just tapping spacebar/backspace four times. –  Pops Sep 25 '10 at 22:04
    
@Popular Demand, those are all 2-key combinations. –  Brad Gilbert Sep 28 '10 at 16:13
1  
@Brad, you don't have to hit <kbd>SHIFT</kbd> for any of those? –  Pops Sep 28 '10 at 16:16
    
@Popular Demand, you do/did for & and !. The first four are the ones I want the most though. –  Brad Gilbert Sep 28 '10 at 16:25
1  
@Brad, thanks for the edit, but on my keyboard, <kbd>SHIFT</kbd> is required for < and >. I guess you could use CTRL+, and CTRL+. as well. –  Pops Sep 28 '10 at 16:28
1  
The problem with these shortcuts is that they only work for American users. For example on my keyboard ] comes from CTRL+ALT+9 combo. So does CTRL+] mean CTRL+CTRL+ALT+9 for me? –  Rookie Jun 17 '12 at 12:31

Please do not make tab key insert an actual tab!

Many users (well, at least this one) rely on the tab key to change focus when they are not using their mouse. It would break a fundamental UI feature that's been around in data entry forms (on and off the web) since at least Windows 3.1.

I'd suggest to use spaces if you are entering code in the editor. If you have an unusually large block of code, you're probably copy/pasting from an IDE anyway.

If you still want to break tab behavior, there's a StackApp for that.

share|improve this answer
1  
I think a textarea field is the one exeption to this... how would one enter a tab then otherwise, without copying/pasting it from somewhere else? –  fretje Jun 30 '09 at 13:56
2  
well that's how textareas work. like it or not, this site would be different from pretty much everywhere else on the internet. i don't consider that user friendly –  Kip Jun 30 '09 at 14:02
1  
It wouldn't differ from those that expect large blocks of text. Go try a forum text editor or a e-mail client. Where large text is presumed the tab works as it would in a offline editor. –  Damien Jul 2 '09 at 15:46
5  
We're writing code here. Tab is quite natural thing with code. Instead, "Add Comment" could get a shortcut such as Ctrl+Shift+Enter. –  Ivan Vučica Jul 10 '09 at 12:47
1  
@Damien: can you provide some examples of forum text editors or e-mail clients on the web where tab inserts an actual tab? Gmail and Hotmail do not override tab when writing messages. Yahoo overrides it, but even there it doesn't insert a tab, it just does nothing. i tried a couple message boards i'm aware of, and couldn't find any that override tab. –  Kip Jul 10 '09 at 13:50
    
Shift-tab out or similar. –  Won't Jul 22 '09 at 16:12
2  
+1. DO NOT CHANGE TAB BEHAVIOR! Look to Jon Skeet and Brad Gilbert for the correct behavior changes. –  Randolpho Jul 22 '09 at 17:34
2  
I disagree. When I'm in an editor and I press 'tab' more often than not it's because I want to want to add a tab space. It's what I expect and hence more user-friendly than consistency in this case, at least. Come on! I have even implemented a workaround for textarea fields, I can post it somewhere if I knew where. –  Robin Maben Aug 8 '12 at 9:19
    
@RobinMaben: you can make it into a user script and post it on stackapps.com but it looks like a similar script already exists: stackapps.com/questions/3247/… –  Kip Aug 9 '12 at 13:55

I stopped using the editor for code editing a long time ago. I just fire up an IDE and do it there, just remember to indent the entire codeblock by one tab and select and copy paste.

share|improve this answer

Overriding system shortcuts is a bad thing. I can no longer paste into the text editing field without using the mouse, using Mac OS X, on a Dvorak/Cmd-Querty keyboard. (Cmd-V converts into "Code", which is Ctrl-K).

share|improve this answer
    
How can we resolve this without taking away features from eveyrone else? –  Brad Gilbert Jul 23 '09 at 0:19
1  
I reported a bug to the Webkit team about this, as I don't think it can be resolved from stackoverflow.com's perspective. –  Andrew Pouliot Mar 25 '10 at 20:37

Priority list IMHO:

  1. Fix the Chrome blockquote bug (or have it fixed)
  2. Make further efforts to match a post's preview and the actual rendering (this list appears correctly in the preview, see item "6")
  3. Autoindentation (see Jon Skeet's answer)
  4. Autoindent lists (so that if I pressed Enter right now, it would move on to item 4)
  5. Add a character palette for all sorts of useful characters from m-dashes to backticks and tilde (not everybody has them on their keyboard) to arrows block drawing characters to mathematical operators. For example: (Mr. &shy; makes this look misaligned)

    ┌─┬┐ αµ ~∀ ±− ­ ↖↑↗ “” 
    │├┼┤ βϱ `∃ ײ – ←⇔→ ⇐⇒
    └─┴┘ πω ¬∈ ÷³ — ↙↓↘ ⊂⊃
    

6. Make it less annoying to copy and paste data from the post preview.

share|improve this answer
    
This is a good example of a broken formatting feature (point 6) –  scrowler May 27 at 18:41

Have the title field as a textarea so that browsers' spell checking functionality works there as well.

my tongue is only slightly in my cheek here

UPDATE I've just discovered that Google Chrome can spell check text boxes, but it appears to be on a per page or site basis as I have to keep re-enabling the option.

share|improve this answer
    
This is a good one actually... –  Damien Jun 30 '09 at 13:36
7  
In Firefox, about:config - change layout.spellcheckDefault to 2 (Enables spell-check for single line inputs kb.mozillazine.org/Layout.spellcheckDefault ) –  dbr Jul 1 '09 at 3:52
1  
@dbr - didn't know that. I wonder if there's something similar for Chrome? –  ChrisF Jul 1 '09 at 7:54

I think it would be better if the editor and the preview panes were horizontally aligned, even if it would temporarily hide the right sidebar's content ():

+-------------------------------------------------+
| o o o             Stack Overflow                | 
| < > + - [≥ http://stackoverflow.com/          ] | 
|_[ StackOverflow ][ tab2 ]_______________________| 
|                                                 | 
| B I | @ “ {} [] | < >                           | 
| +---------------------+  +--------------------+ | 
| | Editor source       |  | Preview            | |  
| |                     |  |                    | | 
| |                     |  |                    | | 
| |                     |  |                    | | 
| +---------------------+  +--------------------+ | 
|                                                 | 
+-------------------------------------------------+ 

If the editor area could autogrow, then the actual contents in the source and the preview panes would be approximately aligned, thus extensive vertical scrolling (in the editor area AND the page) could be entirely avoided.

share|improve this answer
    
When optional, like if fluently adjusting to your browser's window size, then I would not mind. But I'm rarely using a width that fits 660 pixels twice, and would dislike any site requiring that. –  Arjan Jun 17 '12 at 14:36

You should be able to paste in the raw URL to a question and the editor will auto-link it with the title of the question. This alone will save me a bunch of time in copying and pasting twice to link a question.

share|improve this answer
    
Or a title / link fields in the url box. –  Ólafur Waage Jun 29 '09 at 9:46
2  
status-completed –  badp Jan 14 '11 at 19:56

Cheers,

It was suggested to me that I should post here a request fixing problem with AltGr+G on Croatian keyboards. Basically, AltGr+F is used to insert [, and AltGr+G is used to insert ] on Croatian keyboard.

More details here.

share|improve this answer

I'd like the editor to write the code I mean, not the code I type. It should be smart enough to correct any usage errors I make due to the lack of intellisense. A unit testing framework that allows me to check my code for errors would be nice, too.

:-J

share|improve this answer
    
-1 not a real answer, +1 funny –  Pops Sep 28 '10 at 16:30

In case anyone wants to try out how it feels live:

Try Codility's Demo test.

It supports both the tab-key and auto-maintains the indentation level. Myself, I love it.

edit: stumbled upon http://compilr.com as well

share|improve this answer

I want to make a case for TAB key adding tab-spaces -

  1. I disagree with this explanation.

  2. When in a code-editor, pressing 'tab' more often than not is because I want to want to add a tab space.

  3. It's what one would expect in that context. And hence more user-friendly than consistency! (Come, on!)

PS : I have even implemented a workaround for textarea fields, I can post it here but not sure that's required/considered.

share|improve this answer

I find it annoying too - especially when writing code, or pasting code in from Visual Studio and then trying to use hightlighting and tabs to move it to the left.

Using "Shift tab" or "Alt tab" (well perhaps not this combination, but you get the idea) might be a compromise.

share|improve this answer
2  
Alt tab? Did you think about that before you suggested it? :P –  musicfreak Jun 29 '09 at 9:15
    
No :) - just thinking of a modifier on the tab key. Thanks! –  ChrisF Jun 29 '09 at 9:18
    
Haha no problem. I had to actually go and try out the combination to see if I found it natural before I realized something was wrong. :) –  musicfreak Jun 29 '09 at 9:21
1  
Ctrl-Tab switches tabs in the browser (MDI) and Shift-Tab means back-tab. So none of the simple modifiers are available. –  Dennis Williamson Jun 29 '09 at 13:14
    
@Dennis - Damn, but you get the idea - perhaps typing \t then? –  ChrisF Jun 29 '09 at 13:23
2  
But then what if you want to actually type "\t" - argh!!! –  ChrisF Jun 29 '09 at 13:24

Please don't force my browser to act like a desktop text editor!

There's already problems with seemingly simple things like trying to give the editor keyboard shortcuts.. For example, the code-block command Ctrl+k invokes the delete-selection emacs'ish command in Camino.

Messing with the inputs indentation really isn't a <textarea>'s job, and that's all the "editor" really is! I imagine such a feature could easily screw with pasting into the input box, for example.

This pushes a simple textarea into the "The Uncanny Valley of User Interface[s]", something I feel the WMD editor has quite successfully avoided (disable Javascript and this box basically works the same, minus the preview)

The editor isn't too bad for writing code.. For single-level-of-indentation code, I generally write it with no indentation, then use the ctrl+k shortcut to indent the first level, then select the rest of the code and hit ctrl+k again.. I'll try and demonstrate..

Step 1 (write script with no indentation):

if(true){
something()
}

Step 2 (select the lines and ctrl+k to indent it):

if(true){

    something()

}

Step 3 (remove the extra two lines, select all the code, press ctrl+k to make it into the final code-block):

    if(true){
        something()
    }

If I want to write code with anything more than one level of indentation, I just copy the answer-text into to a proper text editor (which I'm sure most users have open anyway!)

There's a good Firefox addon for this, actually. "It's All Text!" adds a little "Edit" button to each input box.. When clicked it loads the current text into your editor-of-choice.. When you save the file, the textarea is updated and you can post your answer. Same as the copy-and-paste to a proper editor, with less key-strokes!

share|improve this answer
1  
Coding community == code-focused editor. –  Ivan Vučica Jul 10 '09 at 12:50
2  
Javascript == crappy basis for a code editor, was more my point! –  dbr Jul 10 '09 at 14:05
4  
+1. DO NOT CHANGE TAB BEHAVIOR! Look to Jon Skeet and Brad Gilbert for the correct behavior changes. –  Randolpho Jul 22 '09 at 17:35

Please have the tab work in the editing textbox instead of taking the focus elsewhere.

share|improve this answer
3  
"have the tab work in the editing textbox" === "taking the focus elsewhere" –  Kip Jul 22 '09 at 18:44
1  
@Kip, No if the tab works in the editing textbox, then the focus will stay there and not go elsewhere –  Lance Roberts Jul 22 '09 at 19:01
1  
not in my web browser –  Kip Jul 22 '09 at 19:04
1  
That's the problem with SO's textbox, the tab takes the focus elsewhere. After I tab, I always have to mouse-click in the box again (and then use the spacebar repeatedly). –  Lance Roberts Jul 22 '09 at 19:11

I get that the StackOverflow questions/answer box is not for any sort of serious code editing, but a couple toolbar buttons + keyboard shortcuts for performing indent and outdent would be a very nice upgrade. It would benefit both code editing and list editing.

Suggested keyboard shorcuts (keeping in mind that tab and shift-tab are not really a good option within a browser): Ctrl+</Ctrl+> and/or Ctrl+[/Ctrl+]

In addition, being able to maintain the same level of indent when pressing enter would be equally as valuable.

Sure, we could all switch to a dedicated text editor when typing code, but that adds unnecessary friction to the process when you just have a few lines to type. Good user experience is all about minimizing this type of friction, and indenting/outdenting is a pretty common use case.

share|improve this answer

I don't know if this was the case when this question was asked, but Shift+Enter continues the current Markdown line formatting:

In code, I press Shift+Enter
<-- and end up here.
  • Similarly, in a bullet list
  • Shift+Enter put me here.

It doesn't work for a simple formatted block

However,

If you include a space it works again (but you need two spaces at the end of the line
to get this format to display with a new line).

share|improve this answer
    
Interesting observations! The code version puts an 'enter code here' block on the next line, but it is selected so any typing gets rid of it. This isn't a full autoindent; if your line is indented eight spaces (body of function, etc), the shift-enter indents four spaces, not eight. Pity! The bullet list is similar in that it generates some selected text. The bullet list behaves slightly differently depending on whether you have space-asterisk or just asterisk at the start of a line (double spacing if you have no space). And numbered list items are converted to bullet list items. –  Jonathan Leffler Feb 24 at 1:29

You must log in to answer this question.

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