Remove blank (empty) lines
-
welcome to the notepad++ community, @Andrew-Bruce-Chwatt144
I must be very stupid …
no, not at all, it’s the same for all of us.
I select a section (right-click and hold, select, release right-click)
Edit > Line operations > Remove Empty Lines and NotePad++ removes ALL the empty lines in the entire document!unfortunately the menu
edit > line operations > remove empty lines
only handles the entire document.but you can remove empty lines from a text selection, by installing the textfx plugin.
once textfx is installed, select the text you want to handle, and go to the menutextfx > textfx edit > delete blank lines
as shown at the screenshot below.textfx install guide for notepad++ version 7.6.3:
to install the textfx plugin, go to the menuplugins > plugins admin
enter textfx in the search bar and hit next until you see textfx characters.
mark it and hit install as seen at the screenshot below.if you have an older version of notepad++, please post your debug information here, so we can make a guide for you if necessary
(menu: ? > debug info)i hope this was of service.
-
Delete blank lines (containing space characters) , this does not suit you?
-
Delete blank lines (containing space characters) , this does not suit you?
unfortunately not. the built in “delete blank lines” deletes all blank lines in a document.
@Andrew-Bruce-Chwatt144 needs to only delete blank lines from the part of the file he has selected (marked), and not the entire document.
-
Very many thanks!
I had to convert to the 32-bit version to get it working, but that’s no big deal.
What a pleasure! I was SURE that I was being stupid and missing something.Allbest
Andrew
-
thank you for reporting back, glad you got it running. 👍
also thanks for the reminder, that the textfx plugin is not available at the notepad++ x64 plugins admin. my apologies, i completely forgot about that.
ps: notepad++ 32 bit is fine, as long as your documents are smaller than about 512mb (i’m on 32 bit to, for compatibility reasons and more available plugins).
note: if you ever want to play around with textfx 64 bit in the future (has to be installed manually):
@chcg recently pointed out that the experimental textfx 64 bit plugin dll can be downloaded here:
https://github.com/HQJaTu/NPPTextFX/blob/VS2017-x64/bin/x64/NppTextFX.dll
(see his original post >>> here <<<) -
Good that the OP got it working, but after the fact I’m thinking that a regex solution would have been simpler.
-
but after the fact I’m thinking that a regex solution would have been simpler.
yes, you are correct.
unfortunately no-one posted a regex solution yet (s.h) 😉regex solution to remove all empty lines from a marked selection:
-
mark the text section, where all empty lines should be removed
-
open the menu:
search > replace
and enter:
find what:
^$\R
replace with: (leave this empty)
search mode: regular expression- check “in selection” and hit replace all
note: only completely empty lines, without spaces or tabs, will be removed using this example.
-
-
Interesting why you chose
^$\R
over the simpler^\R
… So yes, these will get truly empty lines.To get lines which appear empty as well, but may not be, go with
^\h*\R
. -
Interesting why you chose ^$\R over the simpler ^\R
just for you alan, just for you 😉
you are right again.
i guess it’s because i’m used to pcre/php regex style (thus my often different syntax, and abundant use of non greedy wildcard patterns) and binary safety (theoretical sequence of lf, cr, lf or cr, cr, lf). but in this case such thing will never happen, and even if it would, with an additional lf or cr, my example would not delete the empty line, as it is of course not empty …… in other words: my
$
is just complete and utterly useless 😂😂😂 -
Thanks all for your help - a couple of no so very obvious tips for dopes like me.
-
Don’t be surprised if the Notepad++ 32bit x86 that you installed to get TextFX working automagically transforms itself to Notepad++ 64bit x64 and nice new TextFX disappears. Most peculiar - may have something to do with an update? Never seen that sort of behaviour before and no, I have not been eating magic mushrooms and I know where my apps and stuff live.
-
Download the 64bit version of NppTextFX.dll as above, but WAIT!
First of all you’ll have to create a nice new little folder called NppTextFX for NppTextFX.dll to live in. Now you can put the 64bit version of NppTextFX.dll in its own little folder and all will be happy. Just plonking it in the Plugins folder don’t work.
Thanks everyone!
abc
-
-
This post is deleted!