GitHub markdown shortcut to treat text as code

githubkeyboard shortcutsmarkdown

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

Best Answer

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