Text Field Seperator
-
Hi,
How can I make vertical field separator (lets say every 8 characters) like the “Tabs” but starting from top and going all the way down to the bottom of the text file?
Thank you!
-
Maybe doing a macro is a good idea ?
-
Hi A2020,
Again, a regular expression seems to be the nice solution !!
So, follow the steps, below :
-
Place your cursor at the beginning of the text to separate ( I chose the
|character as separator ! ) -
Open the Replace dialog ( CTRL + H )
-
Set the Regular expression search mode
-
Uncheck, preferably, the Wrap around option
-
In the Replace with zone, type the simple regex
$0|
Now, from an original example text, below :
1234567812345678123456781 12345678123456781234 12345678123456781234567
-
If you would like this kind of resulting text :
12345678|12345678|12345678|1
12345678|12345678|1234
12345678|12345678|1234567
Type, in the Find what zone, the regex
(?-s).{8}Note :
ONLY, standard characters are counted, in order to reach a 8-characters string !
-
If you would like this kind of resulting text :
12345678|12345678|12345678|1
123|45678123|45678123|4
12345|67812345|67812345|67
Type, in the Find what zone, the regex
(?s).{8}Note :
In that second case, we count the two Windows End of Line characters (
\rand\n), as part of the 8 needed characters !
-
If you would like this kind of resulting text :
12345678|12345678|12345678|1
1234567|81234567|81234
123|45678123|45678123|4567
Type, in the Find what zone, the regex :
.{8}|.{7}\R+.{1}|.{6}\R+.{2}|.{5}\R+.{3}|.{4}\R+.{4}|.{3}\R+.{5}|.{2}\R+.{6}|.{1}\R+.{7}Note :
Like in the first case, the End of Line characters are NOT taken in account. However, this time, the counting process goes on, through the multiples lines crossed !
Remark :
Of course, in these regexes :
-
The quantifier
{n}can contain any other integer than the 8 digit -
In each alternative
.{n}\R+.{m}, of the 3rd regex, the sumn + mrepresents the total of characters needed, before the separator character added
Best Regards,
guy038
-
-
Thanks for all your comments but I don’t want to actually separate the texts!,… just need an indicator to show me where I am,… please see the example below:
https://drive.google.com/file/d/0Bye-nObSi7obaC1CaHhNVEN4aGs/view?usp=sharingThanks again.
-
Something like that isn’t quite possible. There is a single edge line that can be set but Scintilla (the part of Notepad++ that handles the text) doesn’t support multiple lines.
However with a plugin you could do something like set the background alternating between two colors (e.g. a light grey and dark grey) every 8 characters. Not exactly what you want but may be sufficient.
-
Actually I think the plug in would work for me just as you described it, could you please let me know its name or where I can find it,…?
Thank you.
-
Nothing exists (existed?) that does it. However I wrote a quick piece of Lua to do it. I can’t say the columns are that pretty but this is as close as you will probably get to indicating columns based on width.
- Download the LuaScript plugin
- Extract the zip and copy the DLL to your plugins directory
- Select
Plugins > LuaScript > Edit Startup Script - Paste the chunk of code (See end of this post)
- Edit the first few lines of of the code to do what you want (you’ll probably just need to set the file extensions you want)
- Save and restart Notepad++
- Open one of your files
Again, it isn’t the prettiest but there’s really nothing else I know of that will do what you want. Adjusting colors may help. For example…

The code…
-- Configure things here... local registeredExtensions = {".csv", ".xyz"} local columWidth = 8 local col1Color = 0xd0d0d0 local col2Color = 0xaaaaaa local field_indic = {12, 13} -- not sure what one is best to use but this works local function setupEditor(e) e.IndicStyle[field_indic[1]] = INDIC_STRAIGHTBOX e.IndicStyle[field_indic[2]] = INDIC_STRAIGHTBOX e.IndicUnder[field_indic[1]] = true e.IndicUnder[field_indic[2]] = true e.IndicAlpha[field_indic[1]] = 255 e.IndicAlpha[field_indic[2]] = 255 e.IndicFore[field_indic[1]] = col1Color -- Color of first column e.IndicFore[field_indic[2]] = col2Color -- Color of second column end setupEditor(editor1) setupEditor(editor2) function highlightColumns() local function getLineRangeOnScreen() local firstLine = editor.FirstVisibleLine local lastLine = firstLine + editor.LinesOnScreen return firstLine, lastLine end local function getRangeOnScreen() local firstLine, lastLine = getLineRangeOnScreen() local startPos = editor:PositionFromLine(firstLine) local endPos = editor.LineEndPosition[lastLine] return startPos, endPos end local function clearIndicatorOnScreen() local s, e = getRangeOnScreen() editor:IndicatorClearRange(s, e - s) end -- Clear everything editor.IndicatorCurrent = field_indic[1] clearIndicatorOnScreen() editor.IndicatorCurrent = field_indic[2] clearIndicatorOnScreen() local s, e = getLineRangeOnScreen() for i=s,e do local index = 0 local lineStart = editor:PositionFromLine(i) local lineEnd = editor.LineEndPosition[i] for p=0,editor:LineLength(i),columWidth do editor.IndicatorCurrent = field_indic[(index % 2) + 1] local col1 = editor:FindColumn(i, p) local col2 = editor:FindColumn(i, p + columWidth) editor:IndicatorFillRange(col1, col2 - col1) index = index + 1 end end end npp.AddEventHandler("OnSwitchFile", function(filename, bufferid) -- Always remove it npp.RemoveEventHandler("OnUpdateUI", highlightColumns) -- Check to see if the extension exists for _,v in pairs(registeredExtensions) do if v == npp:GetExtPart() then npp.AddEventHandler("OnUpdateUI", highlightColumns) return end end end)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login