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

I have had many troubles getting code to display correctly, until I finally figured it out after trying to edit a post so incorrectly that a special message popped up telling me that I needed 4 spaces and perhaps I should press ctrl-k. Voila! I repasted my code, highlighted it, pressed ctrl-k and was done. For something that is so simple it should really be mentioned somewhere when you click "Code Sample" in the edit tool bar.

So, I propose a combination of two things:

  • When you click "Code Sample", it should say "to create code block highlight the desired code and click either the braces on the top, or hit ctrl-k".

  • In the help text on the right it should say "all lines of code must be indented 4 lines" (rather than the current "indent code by 4 spaces"), to make it clear that the operation shouldn't only be done to the first and last lines. This is necessary as other similar operations such as [code] on other sites only need to be put at the beginning yet apply to everything until [/code].

share|improve this question

1 Answer 1

There is already at least three ways of learning how to format code in the UI itself.

  1. The code formatting button on the toolbar.
  2. The formatting help button.
  3. The tips section in the sidebar.

screenshot

share|improve this answer
    
@emschorsch: Ctrl+K is just a keyboard shortcut for the button marked 1. in the screenshot, and it's shown if you hover over it, but I guess it could perhaps be made more visible. –  hammar Jan 7 '12 at 8:39
4  
Oh wow I didn't realize that. I guess the problem was I didn't realize you had to highlight the code when clicking one. I guess that is what should be made more clear. In the instructions on the right. –  emschorsch Jan 7 '12 at 8:48
1  
@emschorsch Agreed; the same button being used for inline code formatting and block code formatting based on your selection isn't obvious. I've been confused by it. –  Jeremy Banks Jan 7 '12 at 9:11
    
True, especially when clicking the question mark icon, and then selecting the code tab, the help is short but comprehensive, I feel. Additional popup help text would probably be annoying. And @emschorsch, you don't need to select code before clicking the button; some actually type code and they can click that button and then have "enter code here" pre-selected, ready for typing. But next time such users will probably not use that button, and for self-explaining maybe the text should read "enter code here; indent each next line with 4 spaces too". –  Arjan Jan 8 '12 at 15:01
    
@ems ctrl+k is mentioned in the tooltip, hover your mouse over the {} code sample button –  Jeff Atwood Jan 9 '12 at 1:57
1  
You are right. Maybe I'm just being obstinate, refusing to see that I just didn't look hard enough. But I feel that changing the description to merely make it more obvious that you have to highlight the code before ctrl-k, or that all lines of code must be indented shouldn't be that difficult. I guess the problem is I'm sure anyone who frequents the meta site is already somewhat knowledgeable so its quite a biased sample group, which makes it difficult to know how much clarification is actually needed for newcomers. –  emschorsch Jan 9 '12 at 7:52

You must log in to answer this question.

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