biati-digital / nova-text-tools

Swiss Army knife for text manipulation and selection Sort, Transform, Filter, Delete Duplicates, Encode, Decode and much more...
16 stars 2 forks source link

[Feature Request] "Select Parent" Command #1

Closed iocouto closed 2 years ago

iocouto commented 2 years ago

Coming into Nova from other editors, I miss some of the scope-based selection options I used to have. For example, when editing an HTML file, Nova only has:

But what about if I want to include the current tags in the selection, too? Often, what we really want is to select the entire parent element, in order to move it, copy it or delete it. I think we need a command like:

- Editor -> Brackets -> Select parent: allows us to select the 'parent' of the currently selected text (or where the cursor is). For an HTML file, for example, if we have our cursor inside the text content of an element, it would allow us to select the text as well as the wrapping HTML tags for that element.

Using this command multiple times should allow us to 'grow' the selection to select the next parent up, too. So if I select a <li> element when I first use it, and then use it again, I should have now selected the entire <ul> or <ol> parent.

This, of course, could also be applied to other languages - it all depends on how Nova parses and renders the document 'tree' internally. In processor languages like LESS, Sass or Stylus - that support nested hierarchies - this would be very useful indeed. But even for CSS itself, it would be handy to be able to 'Select Parent' on a style definition, to move it around.

The 'parent' should vary depending on the cursor position

In the case of an HTML file, if I have my cursor inside the text content of an element, I'd expect the entire element to be selected - including both opening and closing tags.

But if my cursor were inside an attribute - eg., inside the src attribute of an <img> tag - I'd expect the attribute to be selected as the 'parent'. Then, if I selected 'Select Parent' again, I'd probably expect the entire element to be selected.

biati-digital commented 2 years ago

We want to include commands to expand selection, i still use sometimes vscode and expand selection was really helpful, does this vscode extension does what you have in mind? expand region, there's an HTML example in the description.

iocouto commented 2 years ago

That looks pretty good! 👍

biati-digital commented 2 years ago

hi @iocouto this has been added in v3.0.0, please checkout the README for more information. You can use the shortcut command+option+right to expand and command+option+left to shrink. You can configure it inside Nova Preferences.

If you find any errors please create a new issue with code examples, language that you are using, how the selection should expand, etc. any info so we can copy/paste to replicate and fix the problem.