Hi, @mpheath, @coises and all,
@mpheath, I first copied the ORG_LF_ANSI.txt file as Lua_LF_ANSI.txt then I ran your last lua script against this file and the files are almost identical, except in the 3 locations below :
[image: 1793099502965-4880d578-51d5-4405-8ec8-a7883a73ba30-image.jpeg]
[image: 1793099529811-36b4d4bd-062a-4df3-82fe-ffd2ea034157-image.jpeg]
Then I copied again the ORG_LF_ANSI.txt file as Lua_CRLF_UTF-8.txt then I ran your last lua script against this file. This time, there are 5 differences, shown below :
[image: 1793099767481-0f7eee6f-9e87-494e-92b1-2ef95fcf4ea5-image.jpeg]
[image: 1793099783194-9b5ec0fe-6c19-49b6-91a1-1c52166e7b61-image.jpeg]
Thus, as a conclusion, your Lua script is quite correct but the last regex solution :
SEARCH (?-s)^(.{1,78})(?:[\x20\r\n]*\z|\x20*\R|\x20+)
REPLACE \1\n ( for Unix files ) or \1\r\n ( for Windows files )
Followed with a Trim Trailing Space operation, seems slightly better !
Now, @coises, you said :
What is the problem to be solved?
Well, I just wanted to point out that, in particular cases, a simple wrapping operation may not give the expected display, from the user’s perspective ! In my opinion, it seems better to use the present @mpheath’s Lua script ( or an equivalent Python one ) or the regex solution above rather than the odd solution provided by the TextFX plugin.
Best Regards,
guy038
Oh…, I forgot to tell you, @mpheath, that I changed the line :
local maxLineLength = 72
By this one :
local maxLineLength = 78
For all the tests !