22

Possible Duplicate:
How do comments work?

How do I add code while writing comments and how do I enter a newline character?

marked as duplicate by Michael Mrozek, Grace Note, Pops, Kev, ChrisF Jan 12 '11 at 20:43

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.

  • Writing what comments? Not sure I understand – Pëkka Jan 12 '11 at 18:41
  • While commenting to an answer / question.. When i hav to include a code sample, there s not formattin option lik available for asking a question – CHID Jan 12 '11 at 18:43
  • 3
    Like this: This is code. – John Jan 12 '11 at 18:44
  • You don't add newlines in comments. If you want to post that much code edit your question (or answer) or post an answer. – ChrisF Jan 12 '11 at 21:21
  • wait, so you can't write code in comments with more than 1 line? – Charlie Parker Jun 20 '16 at 19:32
  • @CharlieParker - Unfortunately, that's correct. Well, you can insert one or more newlines into comments, and the newlines will be preserved, but they will not be displayed. – Kevin Fegan Aug 16 '18 at 21:52
33

You can't put newlines in a comment codeblock, but you can do inline code by using the backtick character. It looks like this

`

and it appears below the escape key on most keyboards which is sometimes the same key as the tilde (for example, on US English keyboards):

~

Surrounding something in backticks lets it appear as an "inline code block" and you could put them almost anywhere you like, even breaking across new lines. int c; c++; sprintf(); but notice there's no coloration, of course.

E.g. typing `something` in the editor produces something on the page

  • thank you. @drachenstern – CHID Jan 12 '11 at 18:46
  • Better to upvote or accept, but I'll take the thanks for now ;) – jcolebrand Jan 12 '11 at 18:47
  • is that the character Yes it works thank you ! – Faizan Dec 30 '12 at 13:22
  • testing thank you – Mansoorkhan Cherupuzha Aug 27 '14 at 10:28
  • test code not code – Marek Sep 23 '14 at 6:58
  • 'something' this is a test – Tyler Nov 30 '14 at 12:07
  • ~something~ this is another test – Tyler Nov 30 '14 at 12:08
  • one more time , cool – Tyler Nov 30 '14 at 12:08
  • this is just a test – kimreik Jan 11 '15 at 0:54
  • you need to place the symbol just before the letter, and no spacing between the back quote and starting letter. ` FYI` :P – ravi.zombie Dec 15 '15 at 2:10
  • test code in comments – Novice_Developer Jun 26 '16 at 7:44
  • 1
    Thanks. I thought they meant the single quote '. Luckily I found this answer in under 4 minutes or I could have earned the "Can't tell a backtick from a single quote" badge. – Elise van Looij Jul 9 '16 at 15:58
  • 2
    And now you're flooded with a bunch of test codes comments. – Gellie Ann Dec 21 '16 at 1:36
  • 1
    This is a test because this was not working for me ok? <br> This is not giving me a line break. I cannot line break. /sigh – Automationtested Jun 6 '17 at 5:47
  • 1
    Just an update, does it still work? Yes, it does. – Stack Underflow Jun 13 '18 at 23:24
6

Place this symbol: ` before and after the code. (On many keyboards, this "backtick" is the button to the left of "1".)

  • @CHID: like drachenstern said, better to upvote or accept. ;) – John Jan 12 '11 at 18:48
  • ¨ds¨ test vfdsfds – Dejo Dekic Jan 28 '16 at 22:00

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