Action
Delete Line in Draft
à la VS Code
Posted by chzzles,
Last update
4 days ago
Deletes the entire line of text where the cursor is positioned and moves the cursor to the end of the previous line, similar to VS Code.
Steps
-
script
// Delete current line, then move cursor to end of previous line let [selStart, selLen] = editor.getSelectedRange(); let [lineStart, lineLen] = editor.getSelectedLineRange(); let text = editor.getText(); let newPos = 0; if (lineStart > 0) { // Character immediately before current line let prevLineEnd = lineStart - 1; // Position cursor at end of previous line if (text[prevLineEnd] === "\n") { newPos = prevLineEnd; } else { // Handle CRLF or edge cases newPos = prevLineEnd + 1; } } // Delete the current line editor.setTextInRange(lineStart, lineLen, ""); // Place cursor editor.setSelectedRange(newPos, 0);
Options
-
After Success Nothing Notification Error Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.