vscode-markdown icon indicating copy to clipboard operation
vscode-markdown copied to clipboard

Add option to set the default language of a code block

Open FieteO opened this issue 2 years ago • 2 comments

Proposal

I am using this extension to write a lot of README files with code blocks of commands that I need to run. Consequently in 95% of the cases, the code blocks will have a bash formatting then:

``` bash
// command here
```.

It would be great if there was an option to specify the default formatting of code blocks so that I wouldn't have to type 'bash' each time I insert a code block.

FieteO avatar Dec 11 '21 21:12 FieteO

Thanks for the feedback.

To me it is not a general use case for most users, so I'm going to leave this open and see what other people think.

You may try to define your own snippet https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets and assign a keybinding to it https://code.visualstudio.com/docs/editor/userdefinedsnippets#_assign-keybindings-to-snippets

yzhang-gh avatar Dec 12 '21 01:12 yzhang-gh

Oh thanks, I didn't know about that yet! For my use case, I have now defined the following snippet:

"Code block": {
	"prefix": ["cbb"],
	"body": [
		"``` bash",
		"$1",
		"```"
	],
	"description": "A code block with bash formatting"
}

FieteO avatar Dec 12 '21 18:12 FieteO