timhor/obsidian-editor-shortcuts

Select/move/delete by sentence

seatrout opened this issue · 5 comments

Something missing from Obsidian at present is the ability to perform operations on sentences, rather than lines.

You can do this in Vim mode, but that has other drawbacks. I can see, sort of, how sentences might be defined in pseudocode

  • (search backwards for "[\?\!\.] " ;
  • search forwards for the same pattern or the end of the text;
  • select everything in between)

but I don't know how to put that into typescript or indeed any language other than Python.

Once a sentence is defined as a unit of movement, you can put in the commands that prose writers need:

  • move to next/previous sentence
  • delete from cursor to end/beginning of sentence (I use this all the time, when I get half way through a sentence and realis it has gone wrong)
  • cut and even sometimes copy sentence.

All of these operations are really useful if you're writing continuous prose. I can have a try myself, but I can't guarantee success.

That's an interesting idea! I can experiment with this over the weekend.

Thank you!

Verdict: I can certainly implement sentence selection using the strategy you've laid out in pseudocode. However, considering the various commands being proposed as well (move, delete, cut, copy), it starts to get out of scope for this plugin.

I'm happy to create a separate plugin though and work on this functionality there instead (unless you'd like to give it a shot yourself). What do you think?

I think that this should maybe be a separate plugin. It would be great if you could make it. I suspect I lack the skill though I guess could try with the help of Marcus Olsson's breakdown and your code. I confess it's a rabbit hole I am trying to stay out of.

Sure, I've scaffolded a new plugin at https://github.com/timhor/obsidian-sentence-navigator. You can follow along there 🙂