@Troglo37 said in Is There a Way to Prevent Pasted Text from Spreading Out with Rows of Spaces?:
Is there a way to make it automatic?
If register a callback to respond to the notification SC_MOD_INSERTCHECK then it can be automated to change the text before insertion. This example code can be added to the user startup.py file. Make sure the PythonScript configuration is set to ATSTARTUP.
import re def event_paste_single_line(args): SC_MOD_INSERTCHECK = 0x100000 if args['modificationType'] & SC_MOD_INSERTCHECK: text = args['text'] if ' episode\r\n ' in text: result = notepad.messageBox('Paste text as single line?', 'InsertCheck', MESSAGEBOXFLAGS.ICONQUESTION | MESSAGEBOXFLAGS.YESNO) if result == MESSAGEBOXFLAGS.RESULTNO: return text = re.sub(r'\s+', ' ', text) editor.changeInsertion(text) editor.callbackSync(event_paste_single_line, [SCINTILLANOTIFICATION.MODIFIED])I added a messagebox to allow a choice rather then being fully automatic with the text change.