6

I have problem when answering or asking questions on StackOverflow

Suppose I have two possible code snippets and I want to ask which is better.

Here is code 1:

@Override
    protected void onCreate(Bundle savedInstanceState) {
// my code here
    }

and here is code 2:

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // my code here     
    }

You may notice that I can put the code in code snippet block But this is not possible if I add Bulleted list just before this code snippet, Like this:

  • Here is code 1

    @Override protected void onCreate(Bundle savedInstanceState) { // my code here }

  • Here is code 2

    @Override public boolean onCreateOptionsMenu(Menu menu) { // my code here
    }

Now, no matter what I try I cannot format my code in code snippet form, even without the short cut ctrl + k.

You can even check and try to edit this question attempting to put the code in code snippet.

Moreover if I have say 30 line of code, the ctrl + K destroys the formatting of code instead of putting in code snippet.

It literally means that if have bulleted list as your first statement in your question/answer you cannot add code snippet.

So,

  • Is this a known bug?
  • Is there any alternative to put code in code snippet. If yes, then how?

marked as duplicate by Aza, animuson, hims056, gnat, Pops Jun 25 '13 at 7:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Oh, whoops. Bad vote, sorry. – Aza Jun 25 '13 at 5:20
6

Try:

  • This is the first bullet

    Then your code here
    
  • Then your second list item

    Then more code here
    

You need to indent by eight spaces, not four, to get code blocks inside bulleted lists.

  • Thanks for the quick answer but isn't that suppose to happen by default, i.e. after I select the code part and do ctrl + k.. – CRUSADER Jun 25 '13 at 5:30
  • @CRUSADER That one's status-bydesign, since you don't always want that kind of formatting. It's a little weird, though. Might want to submit a feature request, but be sure to be clear about what you're asking for – Aza Jun 25 '13 at 5:36
  • how more clear can I get than this, and this occurred to me when I was answering a question on stackoverflow. What I know that ctrl + k means a code snippet format, it has to function that way. Thanks for answering so quick. – CRUSADER Jun 25 '13 at 5:47
  • If you'd like to, feel free to post a feature request! – Aza Jun 25 '13 at 5:48
  • How can I post a feature request, please guide me.. – CRUSADER Jun 25 '13 at 5:49
  • oh, do you mean adding feature-request tag in question above?? – CRUSADER Jun 25 '13 at 6:18
  • Yeah, but I think it's a duplicate. – Aza Jun 25 '13 at 7:12
  • Ok, Thanks for guiding... – CRUSADER Jun 25 '13 at 7:23
  • Wouldn't have guessed that ;) – bonCodigo Jul 17 '14 at 6:05

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