'Add inline footnote' command

Use case or problem

The Add footnote command utilizes numbered footnotes, without an option to insert an inline footnote instead, which one may prefer. Especially if one frequently moves or copies paragraphs that contain footnotes between notes.

Proposed solution

The command would function just like the Add internal link command: if there’s a selection, wrap it in inline footnote syntax. If there’s no selection, insert ^[] with the cursor positioned between the brackets.

Current workaround (optional)

Type out the inline footnote syntax manually or insert a template.

Related feature requests (optional)

I vibe coded a template that supports newlines and works as a toggle:

Templater script
<%*
const editor = this.app.workspace.activeLeaf.view.editor;
const selection = editor.getSelection();
if (selection) {
    const trimmedSelection = selection.trim();
    
    // Check if selection starts and ends with footnote syntax
    const footnoteRegex = /^\^\[(.*)\]$/s;
    const match = trimmedSelection.match(footnoteRegex);
    
    if (match) {
        // Remove footnote syntax and convert <br> back to newlines
        const content = match[1].replace(/<br>/g, '\n');
        editor.replaceSelection(content);
    } else {
        // Replace newlines with <br> only if there are non-whitespace characters after newline
        const processedSelection = trimmedSelection.replace(/\n(?=\S)/g, '<br>');
        editor.replaceSelection(`^[${processedSelection}]`);
    }
} else {
    // Insert footnote template with cursor position
    const cursor = editor.getCursor();
    editor.replaceRange('^[_]', cursor);
    
    // Position cursor inside the brackets (replace the underscore)
    editor.setCursor(cursor.line, cursor.ch + 2);
    editor.replaceRange('', 
        { line: cursor.line, ch: cursor.ch + 2 }, 
        { line: cursor.line, ch: cursor.ch + 3 }
    );
}
%>