Hotkey for inline code and code block

Right now, no hotkey for inline code and code block is available. Since code is frequently used by programmers and statisticians. Hope the team can add hotkey support for them in the next release.


Sorry for the late reply.
IMOH you do not need a Hotkey at all to insert code.
Tabbing the text you want to display as code is the solution.
Or typing 4 or more space in front has the same effect.
You should definitely check the Markdown definitions.

As someone who likes to integrate code snippets into my programming notes, I think a dedicated hotkey for code blocks would be great.

Maybe a small selector for the different programming languages supported by the currently used CodeMirror version in Obsidian would make it even more useful.

This is not a solution to the problem, but a misunderstanding. What you’re describing is QUOTES and BLOCKQUOTES inside markdown files. What @hqgu suggested is actual codeblocks that are supported by Obsidian’s CodeMirror integration.

Current workflow:

Currently when I have a single line of code that I want to have inside my notes, I basically open the command panel and have “toggle code” pinned to the top. This only works for single lines, e.g. this could be a line of code. Alternatively you could bind the “toggle code”-command to a hotkey and press it 3 times.

But if you want to toggle a codeblock, you have to manually set the triple dashes and declare a programming language before pasting your actual code.

# This program prints Hello, world!

print('Hello, world!')

Which takes a bit more time, a few more keystrokes and could really be more comfortable solved than the current implementation.

(Therefore bumping this thread since it could be a great QoL feature.)

You could use the Templater plugin. I think you can set a cursor location, so you don’t start at the end of the snippet.

1 Like

The Code Block From Selection does some of what you want, though it doesn’t toggle codeblocks, only adds them.

1 Like

Why there is only insert code hotkey exists?

Where is insert code block hotkey???