Setting where a command inputs the text in the block

I’m trying to make a custom command “/books” which will add “#Books” and will also mark the block as a TODO. The “#Books” is no problem but because the TODO has to be at the front of the block to be taken as a todo item I’m forced to make sure that I select right at the front of the block. This is usually rather awkward and I’d rather have it function when input at any area. I know this is at least possible when running the “/TODO” command but I can’t find any documentation as to how this is coded in the command. The closest I’ve found is “:backwards-pos” but that isn’t very helpful. It should be noted that my use case for this is tagging blocks that have already been input by Logseq Copilot on Chrome. So it’s not something where I’m starting to type from scratch, I’m always editing an existing block. Thanks!

It’s not possible with the custom command feature. I’d recommend to use the plugin Smart Typing for these kinds of custom input manipulations. For example, what you want can be achieved through this configuration:

trigger: #book
replacement: #book{{callCommand("logseq.editor/cycle-todo")}}

To learn more about the plugin you can visit its home page:

Cool thanks I’ll check it out.

If you have a block and you already need to apply a tag to it via a text expander or custom command, then, after you call that custom command with “<#b” (or whatever), hit <Ctrl+Enter> and the block will be setup as TODO …

Am I getting your question wrong?

Thanks, I hadn’t thought about using the hotkey for adding todo as I . However, that kind of breaks another thing that I commonly do, which is hitting enter when partially typed and having it autofill the rest. I could do a very simple one or two letter command like your example but with my bad memory that won’t scale as the command list grows and I’m forgetting what the pertinent letters are.