Web Applications Stack Exchange is a question and answer site for power users of web applications. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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.

share|improve this answer

GitHub Flavored Markdown supports an alternative syntax for code formatting (notice the backticks):

#include <stdio.h>

int main(void)
    puts("Hello, world\n");
    return 0;

This does not require you to indent the code. Another bonus: you can specify the programming language to enable syntax highlighting:

require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
share|improve this answer
This is the best answer because GFM extends the Markdown standard so you don't need to indent. If only we could get some sort of consensus on what flavor should become the standard. – styfle Feb 22 '14 at 0:19

Select the lines you want to indent and hit Tab twice. Shift+Tab unindents.

share|improve this answer
This doesn't work for me in either Firefox or Chrome. What browser are you using? – Joey Adams Oct 22 '12 at 19:00
@JoeyAdams I've just tried with Chrome and Firefox. Also, it doesn't work in Gist (the editor is just a textarea). – Francesc Rosàs Oct 24 '12 at 23:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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