<?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[How can I delete all rows before or after my current line?]]></title><description><![CDATA[<p dir="auto">In the middle of a huge file - how can I delete all rows before or after my current line - something I miss in the menu. I searched the ‘Line Operations’- part in ‘Edit’ but perhaps this simple feature is still missing in notepad++?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20441/how-can-i-delete-all-rows-before-or-after-my-current-line</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 18:26:18 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20441.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 07 Dec 2020 22:23:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How can I delete all rows before or after my current line? on Wed, 09 Dec 2020 15:56:09 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>: That 2 shortcuts work best for me - I don’t just want to keep the cursorline.<br />
Sorry for my stupid question - thread is solved. And the solution is very simple…<br />
Thanks a lot!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60641</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60641</guid><dc:creator><![CDATA[Enno Dünkel]]></dc:creator><pubDate>Wed, 09 Dec 2020 15:56:09 GMT</pubDate></item><item><title><![CDATA[Reply to How can I delete all rows before or after my current line? on Tue, 08 Dec 2020 13:08:59 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> said in <a href="/post/60572">How can I delete all rows before or after my current line?</a>:</p>
<blockquote>
<p dir="auto">with super long files (hundreds of thousands, or millions, of lines), that amount of data can be slow to select and then delete.</p>
</blockquote>
<p dir="auto">I wonder how fast Pythonscript would delete from large files, without any kind of user-selection being made first ; some “one-liners”:</p>
<ul>
<li>
<p dir="auto">delete all characters from start-of-file to caret:<br />
<code>editor.deleteRange(0, editor.getCurrentPos())</code></p>
</li>
<li>
<p dir="auto">delete all lines from start-of-file to line before caret’s:<br />
<code>editor.deleteRange(0, editor.positionFromLine(editor.lineFromPosition(editor.getCurrentPos())))</code></p>
</li>
<li>
<p dir="auto">delete all characters from caret to end-of-file:<br />
<code>editor.deleteRange(editor.getCurrentPos(), editor.getLength() - editor.getCurrentPos())</code></p>
</li>
<li>
<p dir="auto">delete all lines after caret’s line to end-of-file:<br />
<code>p = editor.positionFromLine(editor.lineFromPosition(editor.getCurrentPos()) + 1); editor.deleteRange(p, editor.getLength() - p)</code></p>
</li>
</ul>
<p dir="auto">I didn’t actually try any of these on a super-large file, so they are just provided as “something to maybe experiment with”.  :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60585</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60585</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 08 Dec 2020 13:08:59 GMT</pubDate></item><item><title><![CDATA[Reply to How can I delete all rows before or after my current line? on Tue, 08 Dec 2020 12:53:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a> <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a></p>
<p dir="auto">Yes, <em>Mark</em>’ing has to have some text to mark.</p>
<p dir="auto">Thus, if your regular expression matches zero actual characters (I suppose that is another way of saying it is a type of “assertion”), nothing will get marked/bookmarked.</p>
<p dir="auto">Definitely an easy experiment to try it with <code>^</code> which should hit on every line, but will result in 0 matches for purposes of a <em>Mark</em>.</p>
<p dir="auto">I believe this is by design.  I looked at the code one time, and I believe it sets up different parameters for the “Boost search flags” when one is <em>Mark</em>’ing versus <em>Find</em> / <em>Replace</em>’ing.</p>
<p dir="auto">I wasn’t pursuing exactly that, but I noticed it when stepping through code, playing around with something else, as a search was being set up.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60584</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60584</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 08 Dec 2020 12:53:30 GMT</pubDate></item><item><title><![CDATA[Reply to How can I delete all rows before or after my current line? on Tue, 08 Dec 2020 00:20:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a> said in <a href="/post/60573">How can I delete all rows before or after my current line?</a>:</p>
<blockquote>
<p dir="auto">thus ONLY contains the file end marker (which by the way isn’t visible even when “View/Show All Symbols/show all characters” is ticked)</p>
</blockquote>
<p dir="auto">AFAIK, that’s because the end of file marker isn’t a character in the file (it’s not like the DOS <code>^Z</code> days where the EOF marker character was part of the file bytestream)</p>
<blockquote>
<p dir="auto">I can’t seem to bookmark it with a regex</p>
</blockquote>
<p dir="auto">I couldn’t either.  I tried with <code>\Z</code> too.  That works for finding the line in FIND, but in MARK, it won’t bookmark the line. I think you are right, that there has to be something for the MARK/BOOKMARK to latch on to from the dialog box.  Interesting.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60575</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60575</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 08 Dec 2020 00:20:02 GMT</pubDate></item><item><title><![CDATA[Reply to How can I delete all rows before or after my current line? on Mon, 07 Dec 2020 23:41:33 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> said in <a href="/post/60572">How can I delete all rows before or after my current line?</a>:</p>
<blockquote>
<p dir="auto">then FIND=^.*$</p>
</blockquote>
<p dir="auto">About the only thing I can see which would be better is to use <code>\R</code> instead. It catches the same number of lines but is shorter and may be quicker from the regex engine point of view. And yes I now think the OP wants the ability to do <strong>either</strong> before or after. My initial interpretation was <strong>both</strong>, but in hindsight <strong>either</strong> seems more logical.</p>
<p dir="auto">The only reason I posted was because with testing I found that if the very last line is an empty line, thus ONLY contains the file end marker (which by the way isn’t visible even when “View/Show All Symbols/show all characters” is ticked) then I can’t seem to bookmark it with a regex, I can manually.  Also tried using the boundary (\b) but it doesn’t mark that very last <code>empty</code> line. Intriguing, or am I missing something? It would seem that to bookmark a line requires a full-width character (including the CR or LF codes), is that correct?</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60573</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60573</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Mon, 07 Dec 2020 23:41:33 GMT</pubDate></item><item><title><![CDATA[Reply to How can I delete all rows before or after my current line? on Mon, 07 Dec 2020 22:43:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/enno-d%C3%BCnkel" aria-label="Profile: Enno-Dünkel">@<bdi>Enno-Dünkel</bdi></a> ,</p>
<p dir="auto">There’s a way to <em>select</em> from the cursor to the end or beginning of the file, by default with <code>Shift+Ctrl+END</code> or <code>Shift+Ctrl+HOME</code><br />
<img src="/assets/uploads/files/1607380389097-9f02112d-2ad1-47f6-ba51-bcd13ce42138-image.png" alt="9f02112d-2ad1-47f6-ba51-bcd13ce42138-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">With “normal” size files, those work find, followed by <code>DELETE</code> or <code>BACKSPACE</code> to delete them.</p>
<p dir="auto">However, with super long files (hundreds of thousands,or millions, of lines), that amount of data can be slow to select and then delete.</p>
<p dir="auto">Oh, while I was typing, <a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a> replied with a different interpretation.  If you really want to keep just the line your cursor is on and delete everything else, then that solution is better than what I explained.  But if you want to keep half the document (either keep before or keep after your cursor) then that solution will delete too much.</p>
<p dir="auto">If you have the text</p>
<pre><code>first
second
cursor
penultimate
ultimate
</code></pre>
<p dir="auto">do you want to end up with  <a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a>’s</p>
<pre><code>cursor
</code></pre>
<p dir="auto">or my</p>
<pre><code>first
second
cursor
</code></pre>
<p dir="auto">Inspired by Terry’s suggestion of Bookmarks, if you only want to delete the lines <em>after</em> the current cursor (per “my interpretation”), maybe arrow down one line, then <strong>Search &gt; Mark</strong>, then FIND=<code>^.*$</code>, Bookmark Line enabled, Wrap Around <em>disabled</em>, Regular Expression mode enabled, then <strong>Mark All</strong>, and then <strong>Search &gt; Bookmark &gt; Remove Bookmarked Lines</strong>.  I don’t know if it’s faster to bookmark every line below the current and then delete them, or to select-then-delete as I initially described.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60572</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60572</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 07 Dec 2020 22:43:51 GMT</pubDate></item><item><title><![CDATA[Reply to How can I delete all rows before or after my current line? on Mon, 07 Dec 2020 22:34:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/enno-d%C3%BCnkel" aria-label="Profile: Enno-Dünkel">@<bdi>Enno-Dünkel</bdi></a> said in <a href="/post/60570">How can I delete all rows before or after my current line?</a>:</p>
<blockquote>
<p dir="auto">how can I delete all rows before or after my current line</p>
</blockquote>
<p dir="auto">A fairly easy solution. Ctrl-F2 on the line you wish to keep. This bookmarks the current line (you will see a blue circle at start of line). Then Use the “remove unmarked lines” which is under “Search” main menu, then “Bookmark” item.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/60571</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/60571</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Mon, 07 Dec 2020 22:34:40 GMT</pubDate></item></channel></rss>