obsidian-apply-patterns-plugin
obsidian-apply-patterns-plugin copied to clipboard
Checkbox: apply pattern to current line in pattern settings
I wish to have "Checkbox: apply pattern to current line if no selection" in pattern settings.
Currently it's required to select whole line first.
I partially automated it with obsidian-editor-shortcuts, set hotkey for "Select line (repeat to keep expanding selection)" but it could be one keystroke instead of two :slightly_smiling_face:
See obsidian-editor-shortcuts code for reference:
https://github.com/timhor/obsidian-editor-shortcuts/blob/4abb250486a10de719c7114f5534ffb6efdd52e0/src/actions.ts#L399-L405:
export const selectLine = (_editor: Editor, selection: EditorSelection) => {
const { from, to } = getSelectionBoundaries(selection);
const startOfCurrentLine = getLineStartPos(from.line);
// if a line is already selected, expand the selection to the next line
const startOfNextLine = getLineStartPos(to.line + 1);
return { anchor: startOfCurrentLine, head: startOfNextLine };
};
https://github.com/timhor/obsidian-editor-shortcuts/blob/4abb250486a10de719c7114f5534ffb6efdd52e0/src/utils.ts#L194C1-L198:
export const getLineStartPos = (line: number): EditorPosition => ({
line,
ch: 0,
});