Hello.
Trying to do the following:
I mark URLS by ‘- [b]’ bookmark in Tasks
I need hotkey which adds ‘- [b]’
I can’t find how to do it. Hotkey for just custom text
Any solution?
Hello.
Trying to do the following:
I mark URLS by ‘- [b]’ bookmark in Tasks
I need hotkey which adds ‘- [b]’
I can’t find how to do it. Hotkey for just custom text
Any solution?
UPD.
Just found a solution.
Plugin Hotkeys++
Edit main.js inside the plugin folder
Add secton:
this.addCommand({
id: 'tbookmarks',
name: 'Task bookmarks',
callback: function () { return _this.tbookmark(); },
hotkeys: [
{
modifiers: ['Mod', 'Shift'],
key: 'b',
},
],
});
and
HotkeysPlus.prototype.tbookmark = function () {
var view = this.app.workspace.getActiveViewOfType(obsidian.MarkdownView);
if (!view) return;
var editor = view.editor;
// Вставляем текст
var textToInsert = "- [b] "; // Замените на нужный текст
var cursor = editor.getCursor();
editor.replaceRange(textToInsert, cursor);
editor.setCursor(cursor.line, cursor.ch + textToInsert.length);
};
Now you can add text - [b] to any place by Ctrl+Shift+b
You can modify main.js as you wish
Templater scripts are easier to trigger inserting strings with key combos.
Also, if you don’t mark the manifest of the plugin as unique ( = rename it), any new updates on that plugin will render your changes non-existent.
With the community plugin Quickadd you can do that and much more.
Check out its capture and macro options!
But in this case, much more than this…
<%*
tR += "- [b] "
_%>
…is hardly needed…
Save this with any filename, register it in Templater to be able to add a key combo to it, done.
I use Templater but I did not know that it is able to do such things Thank you.
I didn’t for a long time, either, I mean with such shortness.
I always declared the workspace, the editor, etc.
But that one line is enough in this case.
But if one needs to work with some variable, e.g. current file name, then they must be declared. E.g. my plantUML generator Python script takes the following syntax:
@puml_gemini filename `start[^]*?end`
So I insert this with:
<%*
const currentFile = app.workspace.getActiveFile();
tR += "@puml_gemini " + `${currentFile.basename}` + " \`start[^]*?end\`";
%>