From time to time I need to include code under a bullet list or number list. When I do this I have to indent blocks of code 8 spaces instead of the typical 4. Is there a keyboard shortcut that will do this? I often use Control + K to do this, but selecting a block and doing this just undoes the indenting in this scenario.

Here's an example of the code block I'm talking about in case you're unaware of this technique.

Normal block of code (4 spaces)

echo "hello U&L world"

Block of code under a list (8 spaces)

  1. some list item #1

    echo "hello U&L world #1"
  2. some list item #2

    echo "hello U&L world #2"
  3. some list item #3

    echo "hello U&L world #3"

2 Answers 2


I just found a really cool usersript that does just that: it enables using tab for indenting code in the SE editor.


Hitting tab twice will double indent so you can easily use it to format code in lists. I've been using this for a few days and can't understand how I lived without it!

  • Confirmed it works. Thanks! Nice dig!
    – slm Mod
    Feb 2, 2014 at 17:32

There isn't, but there's a pretty quick workaround described in WMD: Code inside lists on the main meta:

  • Indent the code 4 spaces with Ctrl+K
  • Add a single non-space character to the beginning of the first line
  • Indent the code 4 more spaces with Ctrl+K (the non-space character tricks the editor into thinking it needs to indent)
  • Remove the character you added to the first line
  • Thanks Michael, I couldn't find it when I searched.
    – slm Mod
    Oct 20, 2013 at 20:40

You must log in to answer this question.

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