<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[improve SCI_LINEDELETE shortcut]]></title><description><![CDATA[<p dir="auto">When I use Visual Studio, pressing 'delete line" shortcut will delete any lines with selection.<br />
Can you make it so that notepad++ SCI_LINEDELETE key mapping to also delete multiple lines when multiple lines are selected. It on delete the 1st line of the selection in the current version.</p>
<p dir="auto">Thanks</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/23096/improve-sci_linedelete-shortcut</link><generator>RSS for Node</generator><lastBuildDate>Sun, 14 Jun 2026 14:13:47 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/23096.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 09 Jun 2022 16:48:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Wed, 23 Aug 2023 16:28:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/88858">improve SCI_LINEDELETE shortcut</a>:</p>
<blockquote>
<p dir="auto">The “caret by itself” situation is handled to delete its line.  Just not “caret by itself on an otherwise non-selected line”.</p>
</blockquote>
<p dir="auto">I prefer less exceptions; but to each his own.<br />
Indeed, scripting solves the differences.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/88860">improve SCI_LINEDELETE shortcut</a>:</p>
<blockquote>
<p dir="auto">Please tell me you aren’t prototyping a Scintilla patch using these scripts you’ve submitted in this thread. Such a patch should be much simpler than that.</p>
</blockquote>
<p dir="auto">I know.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88862</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88862</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 23 Aug 2023 16:28:01 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Wed, 23 Aug 2023 16:16:18 GMT]]></title><description><![CDATA[<p dir="auto">@Victorel-Petrovich said in <a href="/post/88853">improve SCI_LINEDELETE shortcut</a>:</p>
<blockquote>
<p dir="auto">for patch to Scintilla, I’ll probably have to delete the line in both cases, for consistency with SCI_LINECOPY and SCI_LINECUT.</p>
</blockquote>
<p dir="auto">Please tell me you aren’t prototyping a Scintilla patch using these scripts you’ve submitted in this thread.  Such a patch should be much simpler than that.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88860</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88860</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 23 Aug 2023 16:16:18 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Wed, 23 Aug 2023 16:13:42 GMT]]></title><description><![CDATA[<p dir="auto">@Victorel-Petrovich said in <a href="/post/88856">improve SCI_LINEDELETE shortcut</a>:</p>
<blockquote>
<p dir="auto">but since caret by itself can be accepted as marker of line, then it also makes sense to accept it after one(or more)fully selected lines</p>
</blockquote>
<p dir="auto">For you maybe; not for me.  And, as I said, not for a lot of of Notepad++ functions that work for lines in selection.</p>
<p dir="auto">One of the virtues of scripts; everyone can easily have what they want, by tweaking the code.</p>
<p dir="auto">The “caret by itself” situation is handled to delete its line.  Just not “caret by itself on an otherwise non-selected line”.</p>
<blockquote>
<p dir="auto">inverse video</p>
</blockquote>
<p dir="auto">Just a quick way of saying what the text that is selected looks like.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88858</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88858</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 23 Aug 2023 16:13:42 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Wed, 23 Aug 2023 16:12:04 GMT]]></title><description><![CDATA[<p dir="auto">Well, but since caret by itself can be accepted as marker of line, then it also makes sense to accept it after one(or more)fully selected lines. (second pic above).</p>
<p dir="auto">Which “inverse video”?</p>
<p dir="auto">EDIT: it’s not about your script per see (anymore). Just exchanging opinions. Maybe one day I’ll suggest this to Scintilla about all of SCI_ COPY/CUT/DELETE.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88856</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88856</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 23 Aug 2023 16:12:04 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Wed, 23 Aug 2023 15:32:09 GMT]]></title><description><![CDATA[<p dir="auto">@Victorel-Petrovich said in <a href="/post/88853">improve SCI_LINEDELETE shortcut</a>:</p>
<blockquote>
<p dir="auto">It appears you did so on purpose with these lines</p>
</blockquote>
<p dir="auto">Indeed.  If I can <em>see</em> a selection (in “inverse video”), then only likes where I can see that inverse video are the ones I’d want to be deleted.</p>
<p dir="auto">That’s my preference, but it is also the way a lot of Notepad++ line operations work.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88854</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88854</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 23 Aug 2023 15:32:09 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Wed, 23 Aug 2023 15:00:30 GMT]]></title><description><![CDATA[<p dir="auto">Who doesn’t like a bit of praise :)<br />
From my tests of your script,  in following cases:</p>
<ol>
<li>put caret on start of a line, press shift+Down one or more times; the script doesn’t delete the  line where the caret end</li>
<li>Similarly for the line where anchor is at column0, when press shift+Up 1+ times.</li>
</ol>
<p dir="auto">It appears you did so on purpose with these lines:</p>
<pre><code>if sel_start_pos != sel_end_pos and sel_end_pos == editor.positionFromLine(sel_line_end):
    # adjust for case where there is some selected text and caret is on a line by itself, i.e., no actual selected text on line of caret:
    sel_line_end -= 1
</code></pre>
<p dir="auto">Although, I agree it’s debatable whether that line should be deleted in case 2. above : in that case, it doesn’t <em>look</em> like the second line has been touched by selection at all. It looks almost same as when fully select first line from End to Start:<br />
<img src="/assets/uploads/files/1692801640287-87ef58e1-7e93-42a6-beac-06bdc8b8ea8a-capture.png" alt="87ef58e1-7e93-42a6-beac-06bdc8b8ea8a-Capture.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto">On the other hand, in case 1. above, it is clear that the line has been marked:<br />
<img src="/assets/uploads/files/1692801879231-30d5e542-87a9-4cf7-8ee7-69b6f7e1e2d1-capture.png" alt="30d5e542-87a9-4cf7-8ee7-69b6f7e1e2d1-Capture.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto">So, perhaps the ideal rule would be:<br />
Delete all lines either with selection within or where caret resides.</p>
<p dir="auto">But, for patch to Scintilla, I’ll probably have to delete the line in both cases, for consistency with SCI_LINECOPY and SCI_LINECUT.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88853</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88853</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 23 Aug 2023 15:00:30 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Wed, 23 Aug 2023 11:30:41 GMT]]></title><description><![CDATA[<p dir="auto">@Victorel-Petrovich said in <a href="/post/88843">improve SCI_LINEDELETE shortcut</a>:</p>
<blockquote>
<p dir="auto">That’s advanced</p>
</blockquote>
<p dir="auto">:-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88851</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88851</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 23 Aug 2023 11:30:41 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Wed, 23 Aug 2023 04:07:18 GMT]]></title><description><![CDATA[<p dir="auto">That’s advanced; I’ll look into it.</p>
<p dir="auto">Meanwhile, I’ve also been working on a version with looping over selections.</p>
<pre><code>"""
This does not work correctly if some selections share one line (examples: 2 selections or just 2 carets on same line; a selection begins/ends on same line that  another ends/begins); 
In such cases, the program will delete more lines than necessary. 
To solve this, I think would need more than one loop. 
"""
def main():
    editor.beginUndoAction()
    
    selN=editor.getSelections()-1
    while selN&gt;-1:
        p1=editor.getSelectionNStart(selN)
        p2=editor.getSelectionNEnd(selN)
        editor.deleteRange(p1,p2-p1)
        editor.lineDelete() 
        editor.dropSelectionN(selN)
        selN-=1
        
    editor.endUndoAction()
main()
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/88843</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88843</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 23 Aug 2023 04:07:18 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Mon, 21 Aug 2023 15:34:51 GMT]]></title><description><![CDATA[<p dir="auto">If I were updating my original <a href="http://LineDelete.py" rel="nofollow ugc">LineDelete.py</a> script to handle all types of selections that could be active when the user invokes the script, maybe this is how I’d do it:</p>
<pre><code># -*- coding: utf-8 -*-
from __future__ import print_function

# references:
#  https://community.notepad-plus-plus.org/topic/23096/improve-sci_linedelete-shortcut

from Npp import *

#-------------------------------------------------------------------------------

class LD(object):

    def __init__(self):
        line_range_tup_list = []
        for sel_num in range(editor.getSelections()):
            sel_start_pos = editor.getSelectionNStart(sel_num)
            sel_end_pos = editor.getSelectionNEnd(sel_num)
            sel_line_start = editor.lineFromPosition(sel_start_pos)
            sel_line_end = editor.lineFromPosition(sel_end_pos)
            if sel_start_pos != sel_end_pos and sel_end_pos == editor.positionFromLine(sel_line_end):
                # adjust for case where there is some selected text and caret is on a line by itself, i.e., no actual selected text on line of caret:
                sel_line_end -= 1
            line_range_tup_list.append( (sel_line_start, sel_line_end) )
        editor.beginUndoAction()
        # delete lines from bottom of doc towards the top, to avoid having to constantly adjust for previously deleted lines:
        for __ in sorted(list(self.consolidate_tup_list(line_range_tup_list)), reverse=True):
            self.del_line_range(*__)
        editor.endUndoAction()
        # leave single caret:
        __ = editor.getCurrentPos()
        editor.setSel(__, __)
        editor.chooseCaretX()

    def del_line_range(self, start_line_to_del, end_line_to_del):
        #print('start_line_to_del:', start_line_to_del+1, 'end_line_to_del:', end_line_to_del+1)
        start_pos_to_del = editor.positionFromLine(start_line_to_del)
        end_pos_to_del = editor.positionFromLine(end_line_to_del) + editor.lineLength(end_line_to_del)
        #print('start_pos_to_del:', start_pos_to_del+1, 'end_pos_to_del:', end_pos_to_del+1)
        editor.deleteRange(start_pos_to_del, end_pos_to_del - start_pos_to_del)

    def consolidate_tup_list(self, tup_list):
        # inspired by https://stackoverflow.com/questions/5679638/merging-a-list-of-time-range-tuples-that-have-overlapping-time-ranges
        tup_list = sorted(tup_list)
        held_list = list(tup_list[0])
        for (start, end) in tup_list[1:]:
            if held_list[1] &lt;= start &lt;= held_list[1] + 1:
                held_list[1] = end
            else:
                yield tuple(held_list)
                held_list[0] = start
                held_list[1] = end
        yield tuple(held_list)

#-------------------------------------------------------------------------------

if __name__ == '__main__': LD()
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/88791</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88791</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 21 Aug 2023 15:34:51 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Sun, 20 Aug 2023 15:17:57 GMT]]></title><description><![CDATA[<p dir="auto">@Victorel-Petrovich said in <a href="/post/88748">improve SCI_LINEDELETE shortcut</a>:</p>
<blockquote>
<p dir="auto">and who knows how many months till that change will be accepted?</p>
</blockquote>
<p dir="auto">I don’t see (at that Scintilla issue) that you submitted the patch?  Hard to be accepted if nothing is submitted. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88750</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88750</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 20 Aug 2023 15:17:57 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Sun, 20 Aug 2023 14:58:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/88745">improve SCI_LINEDELETE shortcut</a>:</p>
<blockquote>
<p dir="auto">No one thinks you are spamming…</p>
</blockquote>
<p dir="auto">Nice to know.</p>
<blockquote>
<p dir="auto">Are you just practicing your scripting skills in case Scintilla doesn’t address your concern about SCI_LINEDELETE?</p>
</blockquote>
<p dir="auto">That’s right; and who knows how many months till that change will be accepted?<br />
Also, it’s a good general practice, and … a fun challenge :-).</p>
<p dir="auto">Hope will be instructive for others as well happening on this thread.</p>
<p dir="auto">For example, the glitch in my last script:<br />
at first seemed insurmountable, editor.clear() (which is just “delete” function) just doesn’t want to work with several carets<br />
on EOL…<br />
But this morning I thought: what would I do if on keyboard, my “delete” key didn’t work (say, temporarily) ?<br />
Little easy puzzle … and the glitch is gone :) :</p>
<pre><code>def main():
    editor.beginUndoAction()

    if editor.selectionIsRectangle(): 
        p1=editor.getSelectionStart()
        p2=editor.getSelectionEnd()
        editor.deleteRange(p1,p2-p1)
        editor.lineDelete()    
    else:
        editor.deleteBackNotLine()
        editor.delLineLeft()
        editor.delLineRight()
        editor.charRight()
        editor.deleteBack()
            
    editor.endUndoAction()

main()
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/88748</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88748</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sun, 20 Aug 2023 14:58:53 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Sun, 20 Aug 2023 10:32:40 GMT]]></title><description><![CDATA[<p dir="auto">@Victorel-Petrovich</p>
<p dir="auto">No one thinks you are spamming…</p>
<p dir="auto">Are you just practicing your scripting skills in case Scintilla doesn’t address your concern about SCI_LINEDELETE?</p>
<p dir="auto">Ref: <a href="https://sourceforge.net/p/scintilla/feature-requests/1489/" rel="nofollow ugc">https://sourceforge.net/p/scintilla/feature-requests/1489/</a><br />
Ref: <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/13921" rel="nofollow ugc">https://github.com/notepad-plus-plus/notepad-plus-plus/issues/13921</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/88745</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88745</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 20 Aug 2023 10:32:40 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Sun, 20 Aug 2023 04:50:48 GMT]]></title><description><![CDATA[<p dir="auto">I hope that those who think I’m spamming here, have unsubscribed from the topic :) .</p>
<p dir="auto">Next “works” for all kinds of selections (column, not column, mixed…)… BUT … has a little glitch at Ist line in doc for the case of multiple non-column selections: won’t remove EOL for that particular case</p>
<pre><code>def main():
    editor.beginUndoAction()

    if editor.selectionIsRectangle(): 
        p1=editor.getSelectionStart()
        p2=editor.getSelectionEnd()
        editor.deleteRange(p1,p2-p1)
        editor.lineDelete()    
    else:
        editor.deleteBackNotLine()
        editor.delLineLeft()
        editor.delLineRight()
        if editor.getCurrentPos()!=0: 
            editor.deleteBack()
            editor.charRight()
        else:
            editor.clear()
            # compromise: makes it work for single selection, at expense of multi-selections
            
    editor.endUndoAction()

main()
</code></pre>
<p dir="auto">Okay, probably can’t do better without looping over selections…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88742</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88742</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sun, 20 Aug 2023 04:50:48 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Sun, 20 Aug 2023 02:13:19 GMT]]></title><description><![CDATA[<p dir="auto">This one, <em>almost</em> works even for multiple selections (multiple carets).<br />
The only problem is that in such case, the last command <code>editor.clear()</code> refuses to delete the EOL-s, thus it leaves multiple carets in place:</p>
<pre><code>def main():
    editor.beginUndoAction()
    
    editor.deleteBackNotLine()
    editor.delLineLeft()
    editor.delLineRight()
    editor.clear()

    editor.endUndoAction()
    
main()
</code></pre>
<p dir="auto">I should look in how to focus on one selection at a time, in a loop.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88739</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88739</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sun, 20 Aug 2023 02:13:19 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Wed, 16 Aug 2023 05:19:35 GMT]]></title><description><![CDATA[<p dir="auto">2 other versions:</p>
<pre><code>def main():
    if editor.getSelections() &gt; 1 and not editor.selectionIsRectangle(): 
        return  # unsupported for now

    editor.beginUndoAction()
    
    p1=editor.getSelectionStart()
    p2=editor.getSelectionEnd()
    editor.deleteRange(p1,p2-p1)
    editor.lineDelete()
    
    editor.endUndoAction()

main()
</code></pre>
<p dir="auto">and:</p>
<pre><code>def main(): 
    if editor.getSelections() &gt; 1:
        return # unsupported

    editor.beginUndoAction()

    editor.deleteBackNotLine()
    editor.lineDelete()

    editor.endUndoAction()
  
main()
</code></pre>
<p dir="auto">The 2nd one doesn’t work for rectangle selections (column mode), but this is consistent with cutting lines in selection using SCI_LINECUT.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88650</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88650</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 16 Aug 2023 05:19:35 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Wed, 02 Aug 2023 00:18:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a><br />
Oh, so it’s standard python scoping rules at work.<br />
Makes sense. Those classes probably look spooky for beginners :)</p>
<p dir="auto">I’ll stick to functions, at least for now: I can name them same as filename of the script (which needs to be unique anyway).</p>
<p dir="auto">Thank you for the good reply.</p>
<p dir="auto">EDIT: <code>def main(): ... main()</code> should also be enough, provided I do so in EVERY script (as explained by Alan <a href="https://community.notepad-plus-plus.org/topic/24045/pythonscript-plugin-how-to-end-the-script-but-not-quit-notepad/6?_=1690924441132">here</a> )</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88248</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88248</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 02 Aug 2023 00:18:40 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Tue, 01 Aug 2023 18:49:10 GMT]]></title><description><![CDATA[<p dir="auto">@Victorel-Petrovich said in <a href="/post/88243">improve SCI_LINEDELETE shortcut</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a><br />
At your script, is it necessary to wrap the core of it inside a class?<br />
And generally, for any pythonscripts?</p>
</blockquote>
<p dir="auto">It’s not necessary.  But if you’ve got a lot of scripts, there are potentials for namespace collisions (“is the <code>line_start</code> variable in <code>script1.py</code> going to mess up a variable of the same name in <code>script2.py</code>?”).  Alan, and other of us regulars, have lots of scripts that we use on a regular basis, and namespace collisions can create nasty bugs.  By wrapping in a class with a name unique to the script, there is virtually no danger of a namespace collision (unless you don’t pick a unique class name).</p>
<p dir="auto">So those of us who write and/or use lots of scripts tend to wrap them in some way: either in a class, or at least wrapping them in functions and giving the functions long, annoying-to-type names… I used to use a suffix of which Community “topic” number it was (as seen in the URL for each topic) when I would write a function in response to a post here, because that’s a safe way to guarantee that neither I nor the recipient has a function with that exact name already loaded in their PythonScript environment.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88245</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88245</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 01 Aug 2023 18:49:10 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Tue, 01 Aug 2023 20:18:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a><br />
At your script, is it necessary to wrap the core of it inside a class?<br />
And generally, for any pythonscripts?<br />
Because I try just this and seems to work:</p>
<pre><code>if editor.getSelections() == 1 or editor.selectionIsRectangle(): # else, unsupported for now
    editor.beginUndoAction()
    if editor.getCurrentPos() != editor.getAnchor():
        (line_start, line_end) = editor.getUserLineSelection()
        if line_start != line_end:
            start_pos = editor.positionFromLine(line_start)
            end_pos = editor.getLineEndPosition(line_end)
            editor.deleteRange(start_pos, end_pos - start_pos)
    editor.lineDelete()
    editor.endUndoAction()
</code></pre>
<p dir="auto">I’ve read PythonScript 2.0.0.0 documentation , nothing on that.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88243</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88243</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 01 Aug 2023 20:18:38 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Fri, 10 Jun 2022 11:23:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a><br />
Thanks. it works.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/77453</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/77453</guid><dc:creator><![CDATA[Earth Invader]]></dc:creator><pubDate>Fri, 10 Jun 2022 11:23:45 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Thu, 09 Jun 2022 23:24:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/earth-invader" aria-label="Profile: earth-invader">@<bdi>earth-invader</bdi></a> said in <a href="/post/77442">improve SCI_LINEDELETE shortcut</a>:</p>
<blockquote>
<p dir="auto">How do I use your script? I installed PythonScript plugin and placed the script in the script folder but after restart, it still only delete one line.</p>
</blockquote>
<p dir="auto">See <a href="https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript">HERE</a>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/77446</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/77446</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 09 Jun 2022 23:24:54 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Thu, 09 Jun 2022 21:25:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a></p>
<p dir="auto">How do I use your script? I installed PythonScript plugin and placed the script in the script folder but after restart, it still only delete one line.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/77442</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/77442</guid><dc:creator><![CDATA[Earth Invader]]></dc:creator><pubDate>Thu, 09 Jun 2022 21:25:53 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Thu, 09 Jun 2022 20:54:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/earth-invader" aria-label="Profile: earth-invader">@<bdi>earth-invader</bdi></a> said in <a href="/post/77418">improve SCI_LINEDELETE shortcut</a>:</p>
<blockquote>
<p dir="auto">It only deletes the 1st line of the selection in the current version.</p>
</blockquote>
<p dir="auto">Actually, it deletes the line of the caret, which isn’t always the 1st line.</p>
<p dir="auto">If you start making your selection from the top of your window and then lengthen it towards the bottom, when you stop your caret position will be on the bottom-most line, so that one will be the one deleted with SCI_LINEDELETE.</p>
<p dir="auto">If you do it the other way, from lower on the window toward the upper part of the window, then yes, you are correct, the 1st line of the selection will be the one deleted with SCI_LINEDELETE.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/77432</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/77432</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 09 Jun 2022 20:54:09 GMT</pubDate></item><item><title><![CDATA[Reply to improve SCI_LINEDELETE shortcut on Thu, 09 Jun 2022 19:36:14 GMT]]></title><description><![CDATA[<p dir="auto">Here’s a PythonScript called <code>LineDelete.py</code> that implements the functionality:</p>
<pre><code># -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------

class LD(object):

    def __init__(self):
        if editor.getSelections() &gt; 1 and not editor.selectionIsRectangle(): return  # unsupported for now
        editor.beginUndoAction()
        if editor.getCurrentPos() != editor.getAnchor():
            (line_start, line_end) = editor.getUserLineSelection()
            if line_start != line_end:
                start_pos = editor.positionFromLine(line_start)
                end_pos = editor.getLineEndPosition(line_end)
                editor.deleteRange(start_pos, end_pos - start_pos)
        editor.lineDelete()
        editor.endUndoAction()

#-------------------------------------------------------------------------------

if __name__ == '__main__': LD()
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/77427</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/77427</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 09 Jun 2022 19:36:14 GMT</pubDate></item></channel></rss>