Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Kill Lines #26

Open
csuhta opened this issue Feb 8, 2024 · 1 comment
Open

Suggestion: Kill Lines #26

csuhta opened this issue Feb 8, 2024 · 1 comment
Labels
feature request New feature

Comments

@csuhta
Copy link

csuhta commented Feb 8, 2024

I made a tiny plugin to handle this for myself, but it would be something that would fit inside this project and probably be implemented better:

I use ⌘E to kill the current line. Wherever my cursor is, the entire line is deleted. If I have a selection that spans multiple lines, they're all deleted.

Most importantly, this command does not need you to highlight exactly the whole line or entire text you want to be deleted, just wherever your cursor is, whatever you have highlighted, or wherever your multiple cursors are, each line involved is deleted

This is what I did, there is probably a better way to do it:

nova.commands.register("example.delete-lines", (editor) => {
  editor.selectLinesContainingCursors();
  editor.edit((actionQueue) => {
    // When multiple cursors are involved, ranges must be deleted bottom-up
    // so it can be performed as one atomic commit
    editor.selectedRanges.reverse().forEach((range) => {
      actionQueue.delete(range);
    });
  });
});
@biati-digital biati-digital added the feature request New feature label Feb 12, 2024
@biati-digital
Copy link
Owner

Hi, thank's for the suggestion. I'll make some tests with the code you shared. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature
Projects
None yet
Development

No branches or pull requests

2 participants