Hotkey to Toggle Comment Block

I know Obsidian isn’t a code editor, but I use it for code a lot, and commenting out a section of Markdown and prevent it from appearing in the output would be useful.

Command shortcuts can be shared with other editors: How to Comment in VS Code - The VSCode Comment Shortcut

  • On Windows, the shortcut is: CTRL + /
  • On Mac, the shortcut is: Command + /

Hm. This syntax works as a comment in Obsidian for me:

<!-- some text -->

Or is this post asking for a shortcut to do such commenting?

Heh, sorry about that, I added the tag for a shortcut but forgot to include it in the title!

1 Like

Great idea. Revising the title to “hotkey” for consistency with other posts, and adding it to

1 Like

There must be a simple fix that I can’t find, but when I type the close comment string, it’s converted into an arrow -->. I have Smart Quotes and Dashes turned off, which seems to fix it in some apps (like TextEdit), but not others. So annoying. Anyone know how to turn it off?

Hm. Maybe this keyboard shortcut is in your OS? On macOS, System Preferences → Keyboard → Text Replacement tab.

I also have this happen, but I like it. I actually use text replacements to manually expand comments as well, so that I can have the best of both worlds…

dvd, did you ever find a fix for this? I have the same problem, and I can’t figure out why it’s happening. It happens even if I type the closing tag incorrectly, like - - >, and remove the spaces.

I find myself hitting Cmd + / all the time. Taking into account Obsidian Release v0.10.12 I would like to extend the request:

It would be great along with the shortcut to have an option to set which style of comment to use in Obsidian: either <!-- this --> or %% this %%. For example, Github isn’t aware of %% so one might consider using standard HTML.

1 Like

It must be ligatures in the font. Try adding to your custom CSS:

.markdown-preview-section {
  font-variant-ligatures: no-common-ligatures !important;

If Obsidian for Mac were to support the menu bar better and put commands in its Edit & View menu items, then people could set up their own keyboard bindings*.

As it is, I heartily +1 a request for a Toggle Comment Block hotkey, defaulting to CTRL + / (Win) and Command + / (Mac). :slight_smile:

(* shortcuts, hotkeys, whatever you want to call them)

will be implemented in 0.11.1