5

Now that the Stack Exchange network has switched to CommonMark, some features appear to be deprecated. In particular, comment-style language hints may eventually stop working. So instead of using 4-space indentation to format code blocks, we are to use code fences.

But then, shouldn't the automated tools "lead by example" and use code fences too?

Currently we have the following explanation under the Code section of formatting tips:

screenshot of the formatting tip

Note how nothing here suggests the 4-space syntax (8-space being noted specially for code within lists). Yet, if you actually use the suggested Ctrl+K combo (or click the {} toolbar button), you'll get a 4-spaces-indented block, not code fences:

screenshot of the newly-created code block

3

2 Answers 2

4

Either way, I'd like it if some shortcut was retained for indenting. This is very useful in lists:

For example, take:

1. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
```
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
```
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 
  1. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


It's easy to indent the code block and the line below it by selecting the text and using the code block shortcut:

1. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    ```
    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
    ```
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 
  1. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
    

    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

It would be tedious otherwise to indent code blocks, quote blocks etc. by hand for a long list entry.

1
  • 5
    "Either way, I'd like it if some shortcut was retained for indenting." how about a radical solution - Tab indents and hitting Shift+Tab unindents. This way you also fix the absolutely atrocious thing where hitting tab cycles through controls while you want to be writing text. You can further use tab to not only toggle indentation but actually purposefully indent further every time. Then also purposefully drop a level of indentation as well. Helps a lot when you are formatting code, not only Markdown.
    – VLAZ
    Commented Jul 8, 2020 at 10:05
3

The thing is, code fences are already really easy to manually implement into our answers.
Code fences might be the preferred formatting method, but there will still be users who prefer to use indents.

If the Ctrl-K method changed from indenting the code to adding code fences,
how will those who want to indent their code do it as easily as those who manually add code fences?
There are other ways to indent the code, but still, there's Ctrl-K method and there's not much need to change that.

You must log in to answer this question.

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