Is There a Way to Prevent Pasted Text from Spreading Out with Rows of Spaces?
-
This has been bugging me for a long time. Is there a way to prevent Notepad++ from displaying rows of blank space when pasting text from IMDB? I tried all of the settings in the Find box, but nothing happened.
For example, https://www.imdb.com/name/nm0000078/ then click on ‘1 episode’ for Gunsmoke, highlight, and copy Gunsmoke
1 episode 1955See what happens even here?
To remove the spaces easily, I have to either use DuckDuckGo’s search box or the Everything search program to get the result Gunsmoke 1 episode 1955.
Using those prevents the text from spreading out with rows of blank space. All I have to do is click in front of 1955, use the back button 4 times, click in front of 1 episode, then use the back button 5 times.
-
@Troglo37 said in Is There a Way to Prevent Pasted Text from Spreading Out with Rows of Spaces?:
This has been bugging me for a long time. Is there a way to prevent Notepad++ from displaying rows of blank space when pasting text from IMDB? I tried all of the settings in the Find box, but nothing happened.
For example, https://www.imdb.com/name/nm0000078/ then click on ‘1 episode’ for Gunsmoke, highlight, and copy Gunsmoke
1 episode 1955See what happens even here?
Yes. When you copy that text from the webbrowser, the browser puts the string
Gunsmoke\n1 episode\n1955(with newline characters) into the CF_TEXT, CF_OEMTEXT, and CF_UNICODE slots of the Windows clipboard. Then when you paste in Notepad++ (or notepad.exe, or any other text editor which is requesting one of those text slots from the Windows clipboard), Notepad++ correctly pastes what’s there, honoring the newline settings to interpret the newline in the data that you are pasting, just like Notepad++ always does. (And, BTW, pasting that text into Windowsnotepad.exealso correctly puts the newline between the lines, because that is IN THE CLIPBOARD TEXT)Using those prevents the text from spreading out with rows of blank space. All I have to do is click in front of 1955, use the back button 4 times, click in front of 1 episode, then use the back button 5 times.
Notepad++ cannot know that you visually saw a single line in the rendered HTML browser, because all Notepad++ is told is that when it requests the CF_TEXT or similar, there’s a newline there, so it needs to handle that newline the same way it does every other newline in pasted data. To do anything else would break user expectation, and would be considered a crippling bug in the software.
And what you don’t understand is that, even to your browser, that’s not a single line of text. The word
Gunsmokeis in an H3 tag,1 episodeis inside an<li>tag, and1955is in a separate<li>tag. They are three independent pieces of data, which the stylesheet just happens to present as having the two LI elements on the same “line” when rendered. But when your browser puts that data in the clipboard, it separates them with newline symbols. It’s not Notepad++'s fault, and Noteopad++ cannot read your mind in what you “want” from the data: it assumes that since you’re pasting text, that you want to paste the exact text that’s in the CF_TEXT or equivalent slot in the clipboard, so that’s what it does.To save keystrokes to fix it, you can hold down the shift key, hit HOME then UP then UP, the
Ctrl+Jto join the lines.But the “problem” is not on Notepad++'s end. Notepad++ correctly pastes the data that is in the text portion of the Windows clipboard.
-
@PeterJones, I certainly wasn’t being critical of Notepad++ because of this. I’m just surprised to learn that it doesn’t have that feature.
I thought since the Everything search program and the DuckDuckGo search box prevent text from spreading out and keep it all in one line, it would be possible for it to be done in Notepad++, and there are several useful reasons to have that feature (some that I’m not aware of) that others would find useful.
I thought that with all of the functionality in this software, it would have a feature to ignore those codes. Something akin to Paste Special > Unformatted Text, More Options in LibreOffice Writer that could be done with a one-click feature.
-
@Troglo37 said in Is There a Way to Prevent Pasted Text from Spreading Out with Rows of Spaces?:
Something akin to Paste Special > Unformatted Text, More Options in LibreOffice Writer that could be done with a one-click feature.
Have you tried that feature in LibreOffice Writer, with the exact text that you did in Notepad++? Because, as I explained, the newlines are in the plain text version of the clipboard. When you do that exact Paste Special > Unformatted Text, LibreOffice Writer does exactly what Notepad++ does:

… or, in words: it pastes the text in, with the newlines, because that is unformatted text. Newlines aren’t “magic formatting” like HTML<LI>or<H3>are – they are an integral part of the unformatted plain text.“Paste Without Newlines” might be a reasonable feature to a tiny number of people (you, and a relative handful of others)… but Notepad++ doesn’t include it natively, because that’s not a feature that would have broad appeal. (And Notepad++'s normal paste is already the “paste unformatted text”, because that’s literally what pasting the CF_TEXT entry from the clipboard does; you have to use the Edit > Paste Special > Paste HTML/RTF Content actions to get it paste the “formatted” text, though it actually pastes the source code of the formatted text, ie, the raw HTML or RTF rich text, because Notepad++ is not a word processor, which is what LibreOffice Writer is.)
In theory, a plugin could be made specficially for “Paste Without Newlines”… but with just the one feature, that would be a waste of effort. Instead, it would be best as a script in PythonScript or LuaScript. I will probably even spend some time on implementing it in PythonScript today, depending on how much life interrupts.
-
@PeterJones said in Is There a Way to Prevent Pasted Text from Spreading Out with Rows of Spaces?:
implementing it in PythonScript today
Thankfully, I found an old script which did something related, which was easy to update.
# encoding=utf-8 """in response to https://community.notepad-plus-plus.org/topic/27385/ This will paste the CF_TEXT plaintext from the clipboard, but will convert any series of newline characters into a single space before doing the paste. Because this uses .insertText() instead of putting the modified text back into the clipboard and doing .paste(), it should avoid clobbering the clipboard. (based on @alan-kilborn's clipboard script here: <https://community.notepad-plus-plus.org/post/97132>) """ from Npp import * try: editor3h # third editor, hidden except NameError: editor3h = notepad.createScintilla() def get_clipboard_text_without_newlines(): retval = '' editor3h.clearAll() editor3h.paste() if editor3h.getLength() > 0: editor3h.rereplace(r'[\r\n]+', ' ') # replace all newline seqeuences with a single space retval = editor3h.getText() return retval editor.beginUndoAction() editor.insertText(editor.getCurrentPos(), get_clipboard_text_without_newlines()) editor.endUndoAction()This has been tested in the PythonScript 3 plugin. The PythonScript FAQ explains how to install PythonScript plugin, and how to run a script using PythonScript plugin, and even how to assign a keyboard shortcut to the script. Make sure you follow the instructions for PythonScript 3, not PythonScript 2 (as I have not tested under the older plugin syntax, though it will likely work there)
-
P PeterJones referenced this topic on
-
@PeterJones Sorry it took so long. I was dealing with a lot of issues. Washing machine, car, and several other things.
I tried installing Python v3.0.24 msi, and zip Full, but I don’t see it anywhere in the Plugins section. Initially, I installed 2.1. I uninstalled it and tried installing v3.0.24, but 2.1 is still there.
What am I doing wrong?
P.S. I didn’t try any of the v3.0.24 x64, PluginAdmin, Min, or TclTk.
-
I tried installing Python v3.0.24 msi, and zip Full, but I don’t see it anywhere in the Plugins section. Initially, I installed 2.1. I uninstalled it and tried installing v3.0.24, but 2.1 is still there.
What am I doing wrong?
Since you just gave a high-level description, rather than any actual data, it’s really hard to tell.
I uninstalled it and tried installing v3.0.24, but 2.1 is still there.
Then you didn’t uninstall it. Please note that under many conditions, the Plugins Admin uninstall button doesn’t work if Notepad++ has accessed the PythonScript plugin at all that run, because it’s loaded the DLL into memory, and thus cannot delete the file – so if you have any AT START, that virtually guarantees that uninstall button won’t work. (I believe there was an Issue or PR to try to make uinstall button more reliable, but I don’t remember whether that was implemented, or whether it was even feasible.) So, anyway, your best bet is to exit Notepad++ completely, and delete
C:\Program Files\Notepad++\plugins\PythonScript\.P.S. I didn’t try any of the v3.0.24 x64, PluginAdmin, Min, or TclTk.
You didn’t try the 64-bit version of PythonScript? The last time you shared Debug Info (and the time before that) you were using 64-bit Notepad++. So why would you try anything but 64-bit PythonScript. It is 100% guaranteed that it will not work if you try to use the 32-bit PythonScript with a 64-bit Notepad++.
If you ran the 32-bit MSI on a 64-bit OS, it would have tried to install the plugin into
C:\Program Files (x86)\Notepad++\Plugins\PythonScript, which, of course, couldn’t be seen if you are running the 64-bit Notepad++ executable atC:\Program Files\Notepad++\notepad++.exe.If you tried one of the zips, you didn’t say where you put it, or what the directory hierarchy would have been. But if you were still seeing PythonScript 2.1 in Notepad++, it means you didn’t put it in the right place. And I have no clue where you would have put it.
So the things you will need to do:
- Run Notepad++ as normal, and verify with Debug Info that you are using 64-bit, and that it is running from
c:\Program Files\Notepad++.- If you don’t get it working after these instructions, you must share your Debug Info, otherwise it will be impossible to give you better instructions.
- The rest of these instructions will assume normal installation directory, normal 64-bit Notepad++
- Exit Notepad+++ completely. No instances running.
- Go to
C:\Program Files\Notepad++\plugins\PythonScript\. If there’s anything in there, remove it (and the directory) - Grab
PythonScript_Full_3.0.24.0_x64_PluginAdmin.zip(I don’t use the MSI, so cannot give reliable instructions for that MSI installation method). Unzip it so that the following exist:C:\Program Files\Notepad++\plugins\PythonScript\PythonScript.dllC:\Program Files\Notepad++\plugins\PythonScript\python312.dllC:\Program Files\Notepad++\plugins\PythonScript\doc\C:\Program Files\Notepad++\plugins\PythonScript\lib\C:\Program Files\Notepad++\plugins\PythonScript\scripts\
If those aren’t all there, you didn’t unzip things correctly.
- Start Notepad++. It should show PythonScript in the Plugins menu, and Plugins > Python Script > About should show plugin version 3.0.24.0 with Python 3.12.0

If it’s not working for you after following those instructions, you must share
- ?-menu’s Debug Info
dir "c:\Program Files\Notepad++"dir "c:\Program Files\Notepad++\Plugins"dir "c:\Program Files\Notepad++\Plugins\PythonScript"
- Run Notepad++ as normal, and verify with Debug Info that you are using 64-bit, and that it is running from