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
Suggested feature: delete all lines in selection #13921
Comments
I'd call this a "sloppy selection deletion of lines" -- you don't want to go to the precise effort of fussily selecting from col 1 of the first line to col 1 of the first line BEYOND the one you intend to delete. I sense you're not a big fan of mouse operations, but the mouse workaround for this is to click+drag in the line number margin to select entire lines. |
If you're interested in scripting, here's one (I call it
|
Right, I'm not. Besides, I usually disable that margin, and even if not- selection with keyboard is a bit faster if your fingers are already on keyboards. |
The script is the way to go for keyboardists, as running a script can be bound to a keycombo. |
I appreciate you writing that script, I will look into it, but to be really useful: it needs to be combined with "delete" operation so that so that to be triggered by a single shortcut. Just like you can already "copy" or "cut" lines in selection with a shortcut bound to "SCI_LINECOPY" and "SCI_LINECUT". However, I still believe this issue would not be quite solved. |
I already had the script.
It IS useful; I use it often.
No, because that lessens its utility, because you don't always want to delete, sometimes you want to copy or cut... as you go on to point out. If you REALLY want to wrap all of the functionality together, at the end of the script's logic for making the selection, simply add
Well...sure. But apparently you are joining a long line of "script whiners" (definition: those who could have the functionality -- or, close to it -- they want RIGHT NOW, but decline because that functionality isn't built-in, and then goes on to wait, perhaps forever, for that functionality to become native). |
If one has to press 2 key combos in a sequence, one might as well press "home" or "end" key before starting selecting.
I guess they decline because they are intimidated by scripts or don't trust them. And then either wait or pick another editor. I'll personally take the script, but also wait for built-in: faster, cleaner editor overall. |
Back to the script: (I think same argument could be made for purpose of copy or cut functionality, if it didn't exist already). |
That doesn't mean I don't find your script useful; I'm just a bit perfectionistic sometimes. |
So...modify the script as I suggested, to get all-in-one behavior.
I don't understand this statement. How does one (natively) copy/cut on a whole-line basis, when the first and/or last line of a multiline selection is partial?
Sure, but I made the script for my usage long ago, not for your specific need due to this thread. Modify the script as you see fit. |
Ah, I'm catching on:
These commands do indeed operate on the full lines of a partial selection. I'd say since that's the case, the lack of symmetry with SCI_LINEDELETE is a Scintilla bug (of omission). You might want to file a report on the Scintilla site and see what the authors of that project respond with. https://www.scintilla.org |
Found 2 other similar requests/wishes (many more outside Notepad++): In the first link, the best they came up with was recording macro of several operations (like: join-lines, HOME, shift+END, SCI_LINEDELETE), but that is not consistent with SCI_LINECOPY and SCI_LINECUT in all possible cases. In second one, it's a shorter code by you; I installed, tested, and it is consistent with copy & cut.
|
The "LD" (LineDelete) script is originally from HERE. |
I remembered why I prefer the selection to be a separate action from the delete/copy/cut. That way I have only one additional thing to remember (a keycombo for the script that expands current selection to whole-lines). After invoking that, the standard Delete/Ctrl+c/Ctrl+x works for me. I don't have to remember 3 keycombos, one for each of the "enhanced" functionality. |
It's fine to keep discussing further points about this here, but I'm reasonably confident that Notepad++ itself will never make a code change to support what is wanted. IMO Scintilla should bring the behavior for SCI_LINEDELETE into alignment with how SCI_LINECOPY and SCI_LINECUT work. |
I'm going to suggest it to Scintilla. But if they decline, then let N++ do it; hope dies last :) .
Try this: |
I already have those assigned. And I don't have mine assigned to Ctrl+Alt+Shift+w; that was just my suggestion to you because when I suggest such things to people, I don't suggest keycombos that N++ maps by default. To each his own. :-) |
Good luck. |
Neil replied: https://sourceforge.net/p/scintilla/feature-requests/1489/#48c8
|
@victorel-petrovich Are you going to work on such a patch? |
@alankilborn I'd like to, I plan to; unless someone else does it before me.
EDIT:
|
I think you have it backwards. Plugins direct messages to a compiled Scintilla library at the heart of N++'s own compiled source code. What N++ does with the message depends on how N++ (or Scintilla) was programmed. Your feature request would extend Scintilla's functionality. The most that PythonScript can do is test out the new functionality after it's been implemented — in C++. Scintilla's code is hosted in a mercurial repository; you'll want to have the appropriate version control client installed first. |
@rdipardo , correct me if I'm wrong: So it's just easier (for me!) to start with PythonScript. To bridge the abstraction downwards. Makes sense?
I'm not that lost :)
thanks EDIT: perhaps this line of mine
was confusing. I meant a different algorithm than the ones in this thread, at a more char-s level (thus "low level") . |
How I would approach it:
|
Thank you @alankilborn ! EDIT: this page seems to confirm that: https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/BUILD.md Yes, I also figured that "cut" probably works by doing copy then delete, so I could take part of its code. |
Yes.
Again, yes. |
|
You could have left this open, and if Scintilla implements it could be a "closed as completed" (at next Scintilla integration) and that way it might make the Notepad++ change log list when a N++ release supporting it is made. |
Do you know where to find the code for SCI_LINEDELETE function? EDIT: notepad-plus-plus/scintilla/src/Editor.cxx Line 4017 in 7340696
|
The change has indeed been trivial. https://ci.appveyor.com/project/victorel-petrovich/notepad-plus-plus-vic/builds/47875550/artifacts |
Ok, but that doesn't do anything to get Scintilla project to accept the code. Perhaps your plan it to submit the same thing on Scintilla, but then that begs the question, why submit the code here? Just my feeling: You should probably avoid refactoring, unless you really know that is appreciated by the project owners. |
This would have been perfect to ask in the "new" Notepad++ Community area: https://community.notepad-plus-plus.org/category/5/notepad-plugin-development But, since you asked here... The "trick" to finding Scintilla functions is to search for them without the Alternatively, if you DO search for
|
The point of the above posting, even though you already found what you were looking for, is to keep the method in mind for next time you need to do something similar. |
- The "current line" and the "selected lines" are two different "entities". The current
And regardless of Notepad++: |
The implemented behaviour of both SCI_LINECUT and SCI_LINECOPY is unlikely to be changed. And they behave by "lines touched by selection" - that is, including lines where either start or end marker of selection are located. |
Currently, it's only possible to quickly delete a single line (with a shortcut for "SCI_LINEDELETE").
In some other editor I would select several lines (even if not strictly from begin to end of lines) and press a single shortcut to delete all of those lines, in entirety.
It would work similar to how it's possible to cut or copy several selected lines: delete all lines "colored" by selection and including the one where the cursor is.
I used it quite often.
The text was updated successfully, but these errors were encountered: