Wrap using cursor position when in word?

what i’m looking for would be an action that wouldn’t require a selection for wrapping. if the cursor is in the middle of word it would wrap it. a bonus would be wrapping the current line without selection.

thanks in advance

What, exactly, do you mean by “wrapping”? Adding some markup before and after the word/line?

yeah, mainly for my use it would be a single line of code wrapped using the cursor position to select the line. thank you.

There are some examples out there in the directory along these lines, the exact logic you want might not be there, but starting points.

Current line is pretty easy. There’s a method to get the range of the current line, so, this example script would “wrap” the current line in a code block:

// get range of text in current line
let [st, len] = editor.getSelectedLineRange();
// get text of current line
let line = editer.getTextInRange(st, len);
// create new text to replace the line
let newText = "```\n" + line + "\n```\n";
// replace the line with the new text
editor.setTextInRange(st, ln, newText);

Words are a bit trickier. Not necessarily as clear cut to determine where a word begins or ends. There are some examples in the directory, like this “Select Word” action that might be starting points.

excellent! this will get me going. thank you!