SamSuka
noboilerplate
noboilerplate

patreon


[CORRECTED] Obsidian: Using Commander to bind multiple commands to a single hotkey

I was wrong

about binding multiple commands to a single hotkey, not only does this not work, it's non-deterministic and only SOMETIMES doesn't work, which fooled me!

I have tweaked the post to be about the method that DOES work, using the Commander plugin. My apologies for the error, and thanks so much to Sam R for pointing this out to me!

Hi friends, a quick (corrected) Obsidian tip for you.

As you CAN'T bind multiple commands to a single hotkey, I use the commander plugin to build a custom command that combines the four things I want to happen on save:

This new command I have named "Save Hook", which I have bound in the hotkey settings to ctrl+s, and it all works perfectly.

(Note the delay before calling Languagetool, this is so that Linter has had a change to reformat the file, otherwise Languagetool's errors don't line up!)

Explanation:

(1) is obvious, if you're remapping the save key, it should still save the file! Obsidian autosaves, but especially if I'm interacting with external tools, I often need to manually save, too.

(2) Linter is a comprehensive autoformatter for Markdown, which stops me wasting time fiddling with formatting. With it, you can enable auto capitalisation for headings, automatically add blank lines around lists or blockquotes, delete trailing spaces and lines, and many, MANY more. All options are togglable on and off to suit.

(3) LanguageTool Is my preferred "spelling/grammar/and more" checker. The quality of this open-source software is unmatched (Grammarly WISHES it was LanguageTool), and while I can run it locally for offline use, I usually prefer to use the API provided by languagetool.org, which has access to more power-intensive n-gram models. *


(As a writer of historical fiction, THIS IS GENIUS!)

(4) Breadcrumbs provides visualisation and traversal commands for navigating my notes' ontology. Most of my notes have a link to a parent in the file properties, with the YAML key 'up'. I can then use breadcrumbs' commands to navigate to parents, children, etc, without touching my mouse (always a goal). Because rebuilding the breadcrumbs graph can take a few hundred ms, running it after every change is too much, but manually on save is perfect.

More to come, thank you all for your support!
Tris

*You better believe that LanguageTool works in neovim, too! I use barreiroleo/ltex_extra.nvim as my LSP

[CORRECTED] Obsidian: Using Commander to bind multiple commands to a single hotkey

Comments

Sam, you're entirely right. I'm publishing a correction now, thank you very much for making me look closer - it's a race condition or something, I was fooled!

No Boilerplate

Huh, so I don't know if this is a new behavior, but I'm pretty sure I remember using Obsidian when conflicts were OR not AND and could lead to unpredictable outcomes if accidentally multi-mapped like this.

Sam Rogers

Wonderful tip! Completely makes sense that you’d want multiple actions being taken with a single hotkey. Time to test it out and try to avoid race conditions… I’ve recently started writing long form prose in Obsidian and the spellchecker was not enough, and my workflow involves external editors for grammar. Did not know about LanguageTool, so thanks for sharing that!

RantingHuman


More Creators