Horizontal line question
-
@neil-schipper & @JillPlaysMC ,
You can also set Settings > Preferences > Margins/Borders/Edge > Vertical Edge Settings =
129
, which will draw a colored line at character 129, and when you do theCtrl+I
to split the lines, it will split the selected text at that exact location instead of however wide the window happens to be. -
@peterjones how would you ‘split’ at a certain character position without using this setting?
I normally do a regular expression for it, but maybe there’s a quicker/simpler way with the split command?
-
@snabel42 said in Horizontal line question:
how would you ‘split’ at a certain character position without using this setting?
You can’t (well, you can do it with regex but you already know this); it’s all in the USER MANUAL.
-
@alan-kilborn thanks! Thought that was the case, but figured I’d ask once if I was missing something.
This would be a feature request then, a UI or keyboard command to split lines on the fly while also being able to specify the line break character position.
-
how would you ‘split’ at a certain character position without using this setting?
To do a “split”, you either use this setting, or use the complicated process of adjusting the screen width that Neil already described, or do the regex that you claim to know how to do.
Notepad++ is a text editor, not a word processor. It’s not going to automatically re-flow the text as you type like MS Word does and automatically delete and insert actual newline characters because you don’t like the word-wrap as-is.
To do that, you would need to use a word processor, or maybe someone could tell you of a plugin for Notepad++ that does that (but I know of no such plugin). The PythonScript solution would be writing a script which tries to do it “on the fly” as you edit, but would require a custom script, and lots of back-and-forth to develop; beyond that, it won’t be very efficient, so if you’re doing a big file, you might find such a “live script” annoyingly slow. (Unfortunately, you seem to have abandoned going down that road with Ekopalypse; if you really want it on-the-fly, I’d suggest focusing on that, rather than getting distracted).My suggestions for you: do one of the two following options:
- Do it all in native Notepad++, not on the fly.
- Turn on word wrap
- adjust the window width or not, depending on whether you want it closer to the end goal or not
- type all your paragraphs, not worrying about the in-paragraph newlines, and put two newlines between paragraphs
- once done, set the setting to 129 characters, then use
Ctrl+A
to select all your text, then useCtrl+I
to split the paragraphs into individual lines. Clear that setting when you’re done, if the vertical line bothers you.
- If you want it on the fly,
- stop with the diversion into the non-automatic with split
- return to your conversation with Ekopalypse, and hope that he continues to have interest in giving you a proof-of-concept script
- because, while I can do some PythonScript, I would think it would be really complicated to implement and have no implementation ideas
- if Ekopalypse has an idea, more power to you both
- Do it all in native Notepad++, not on the fly.
-
@peterjones I work with a lot system files with a flat structyre, they all have various fixed lengths.
The output however is often transmitted/stored in a single line, or lines that does not match how the system consumes/processes the data.Being able to visually line up the data at fixed line lengths depending on context makes it possible to analyze.
It doesn’t have much to do with preferring it one way or the other, but rather to be able to predict or problem solve the system processing.Most commonly I position to the front of the file and use a simple replace regular expression at whatever file length I need.
Something like this for a line length of 80 characters -
@snabel42 said in Horizontal line question:
This would be a feature request then, a UI or keyboard command to split lines on the fly while also being able to specify the line break character position.
Defining where splits happen is the raison d’être of the Settings > Preferences > Margins/Border/Edge > Vertical Edge Settings box. Literally. It’s the first and primary reason that setting exists. The visible marker is there to help you see where that wrap occurs. But if the reason you don’t want to use that setting is because you don’t like seeing the line, all you have to do is go to Settings > Style Configurator, select Language:
Global Styles
and Style:Edge colour
, and change the foreground color from the current value (cyan on mine) to a color that blends in with your background color (white on mine). Then you won’t see the line, but it will still allowCtrl+I
to wrap there.If you wanted to make a feature request, we have a FAQ explaining where to do that. My guess is that such a “live re-paragraphing” feature wouldn’t be something the developers would be interested in implementing, but I have been known to guess wrongly as to what they will implement.
But as a feature that I would think would be more likely to be implemented, and more generally-useful IMO, would be to have a checkbox on the Vertical Edge Settings section which says “☐ Apply rightmost vertical edge as the Word Wrap margin”, so that the built-in word-wrap feature would make use of the vertical edge setting in deciding where the wrap should occur.
Note: the above was written before your followon post, to which I respond below
----
I work with a lot system files with a flat structyre, they all have various fixed lengths.
Ah. So if I interpret that new information correctly, you don’t really need “live” reformatting, you really are more looking for a one-time-per-file thing that does it? If you have just a few different lengths (maybe 80, 120, and 129), then it would probably be easiest to do a few different search-and-replace macro recordings where you apply the appropriate regex in each). If you need more arbitrary than that, then a PythonScript solution would work, which could be run on-demand for the active file. (It would only be a one-directional script: it would only add the newlines, not remove them). I have an idea for how it would be implmented --when you run the script, it would prompt you for the number of characters; then it would create the right regex based on those characters, and run the regex on the active file – so if you say that manually running this once per file would meet your needs, I can code it up for you and share it sometime in the next hour or two.
-
@peterjones said in Horizontal line question:
I can code it up for you and share it sometime
With that simple requirement of inputting the width and running a regex based on that width, it only took three lines of active PythonScript code (and some boilerplate/comments):
# encoding=utf-8 """in response to https://community.notepad-plus-plus.org/topic/23171/horizontal-line-question/29 This will prompt for a number, and then run a regex to hardwrap after that column """ from Npp import editor,notepad,console colstr = notepad.prompt("Column", "Hard Wrap at Column", 80) # defaults to 80 characters, but you can just type over the value in the prompt box srch = r'^.{' + colstr + '}' editor.rereplace(srch, r'$0\r\n')
For installation/usage instructions, see the FAQ
-
-
@peterjones said in Horizontal line question:
Ah. So if I interpret that new information correctly, you don’t really need “live” reformatting, you really are more looking for a one-time-per-file thing that does it? If you have just a few different lengths (maybe 80, 120, and 129), then it would probably be easiest to do a few different search-and-replace macro recordings where you apply the appropriate regex in each).
I think you nailed it. Each file opened would only ever have a one-time-reformatting need to whatever the appropriate line length happens to be.
I usually can’t know the appropriate length until I actually open the file, but there’s only really so many lengths that are actually used per system/context. Likely building a small library of macro recording would like solve my needs.
I haven’t worked with macros in notepad++ yet, but this seems like a good excuse to start.(I didn’t even think of this as a feature until I saw it done by a colleague in UltraEdit)
-
The script I shared will work for your needs. But if you want to learn how to record and save the macros, then this is a great exercise for it.
-
@peterjones said in Horizontal line question:
The script I shared will work for your needs. But if you want to learn how to record and save the macros, then this is a great exercise for it.
Both methods break new ground for me personally, so I’ll try both for the general experience.
Thanks!
-
BTW: sorry for confusing you two earlier: I didn’t realize that when @Snabel42 jumped in, it was a different user – I wasn’t looking at the user names, and assumed that it was a follow on by the original poster (hence my comment about resuming “your” conversation with @Ekopalypse). My bad.
-
@peterjones probably bad form by me semi-hijacking the thread…
-
@snabel42 said in Horizontal line question:
probably bad form by me semi-hijacking the thread…
Not at all. This is a conversational forum, so the conversation can move or evolve, and different people can get involved. I just didn’t notice the change in user.
It just means that, while a one-time script or macro will work for you, we still don’t know whether @JillPlaysMC needs “live” or whether one-time would work for them as well.
-
@peterjones if it’s interesting, I finally hunted down the relevant UltraEdit wiki page as well as a screenshot of it being used