mirror of
https://github.com/gokulk16/select-current-line-plugin.git
synced 2026-07-22 07:40:26 +00:00
28 lines
701 B
TypeScript
28 lines
701 B
TypeScript
import { Editor, MarkdownView, Plugin } from 'obsidian';
|
|
|
|
|
|
// selects the entire line from index zero
|
|
function selectLine(editor: Editor) {
|
|
const { line } = editor.getCursor();
|
|
const lineText = editor.getLine(line);
|
|
editor.setSelection({ line, ch: 0 }, { line, ch: lineText.length });
|
|
}
|
|
|
|
export default class SelectCurrentLinePlugin extends Plugin {
|
|
|
|
async onload() {
|
|
|
|
// This adds an editor command on the current editor instance
|
|
this.addCommand({
|
|
id: 'select-current-line-on-keystroke',
|
|
name: 'select the current line in editor',
|
|
hotkeys: [{modifiers: [], key: 'Escape'}],
|
|
editorCallback: (editor: Editor) => {
|
|
selectLine(editor);
|
|
}
|
|
});
|
|
}
|
|
|
|
onunload() {
|
|
}
|
|
}
|