Sublime- assign custom-keyboard shortcut for code-block while editing markdown file

(Very short blog on adding a custom keybinding to multi-line code block)

A very quick post for a small time-saving trick in Sublime.

While editing a markdown file having an option to direclty invoke a code block like below with a keyboard shortcut is immensely time saving.


And as of August-2020 in Sublime, I could not find a keyboard shortcut for adding code-blocks either natively from Sublime’s in-built keybinding or an option to add one from in-built commads.

So I am taking help of a third party package Markdown Code Blocks and will add a keyboard shortcut of ‘Ctrl + Shift + z’ for multi-line code block (you can ofcourse assign any other Keyboard combinations to it).

First install the package (Markdown Code Blocks) from Command palette using

Ctrl + Shift + P to open palette > Type ‘Install Package’ and choose the one you see below selected and then search for search for


A command will appear in your command palette.
Search for the command, and type in your desired language name in lowercase letters. And you will see something like below for a .js code formatting


Now time to add a keybinding to invoke the above.

First to know which is the relevant Sublime command (which I have to invoke with a keybinding), after installing open Command Palette > start typeing ‘code blocks’ like below and you will the see the relevant command is this ‘Markdown Code Blocks: Add Block’

So all I had to do is adding a keybinding to that.

Now nevigate to the Github source code of the package which is

And search for the string ‘Code block’ in this repo. And I get the below result.

From the above I can see that the command that I am interested is the below one.

So now from Sublime > Command Palette > Key Bindings > Open my .sublime-keymap file and include the below command

{ "keys": ["ctrl+shift+z"], "caption": "Markdown Code Blocks: Add Block", "command": "markdown_add_code_block" },

And that’s it, now I can invoke the command with

DataScience | ML | 2x Kaggle Expert. Ex Fullstack Engineer and Ex International Financial Analyst.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store