GitHub shortcut for formatting code sample

github

Stack Overflow has a button you can press to indent a block of text four spaces so Markdown will treat it as code. GitHub uses Markdown, too, but does not seem to have formatting buttons.

Does GitHub have a keyboard shortcut or button to indent a block of code, or will I have to copy the code to a text editor, indent it, and paste it back in?

Best Answer

There is no keyboard shortcut to automatically indent a block of code.

You will either have to find a browser extension, like a userscript, or write one yourself. Or just add the four leading spaces as you would now.

You can see a list of current GitHub keyboard shortcuts by Shift + ? and clicking "See all" when on any GitHub page.