While writing an issue in a GitHub repository, how can I:

  • Select a piece of text
  • And press something so that it is treated as code?

For example, here in Stack Exchange I can select a piece of text and press "Ctrl + K" to mark it as code. If I do this in GitHub markdown, it will mark it as a URL instead.

github markdown shortcut code

  • PS: There is a similar question to this one, but it treats code formatting, which is about spacing before the text. – Lucas Bustamante Jan 8 '19 at 15:33
  • Relevant. – Alex Jan 8 '19 at 15:56

In the GitHub editor, a button that looks like <> simply inserts a grave accent ` (also known as a "backtick") around the selected text. I don't see that there's a keyboard shortcut for it, though.

It seems far simpler to me to just add ` before and after your code block. (Which, incidentally, works the same way here.)

The list of available GitHub keyboard shortcuts

  • Thanks @ale, I know how to do it manually, a pitty that there are no shortcuts for it, because I use it a lot. – Lucas Bustamante Jan 8 '19 at 16:58
  • 1
    I have contacted GitHub support, suggesting a keyboard shortcut for code. – Lucas Bustamante Jan 8 '19 at 17:06
  • This is a very dissatisfying answer. I too am looking for a keyboard shortcut for this. Stating that you find it simple not to use a shortcut is not an answer. People who ask this and search for this don't see it that way. – Lukas Aug 27 '19 at 10:41
  • @LucasBustamante did you get any feedback? – Lukas Aug 27 '19 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.