A regex wizard needed :)

You likely want this:

let word = context.matchBefore(/[\w-]*/);

This will match from the cursor backwards to zero or more letters, numbers, underscores, and dashes.

1 Like

Thank you @sukima , your regex works very well

Iā€™m thinking about making it the default

Thanks!
Simon