Frank Wunderlich wrote:
--- Ursprüngliche Nachricht ---
Von: Kein-Hong Man <[EMAIL PROTECTED]>
If you need it often enough that a hotkey combination is
desirable, then I suggest a Lua function... that way, you can make
the function handle CR, LF and CRLF.
a shotcut/menu-entry will be preferred, but i have no knowledge about
lua-scipting...
can you write me this little script to show me how lua-scripting works?
i'd take a look on existing scripts but they are mostly complex for
beginners.
Here is a function that should work. To install, read the file
SciTELua.html in the SciTE documentation and check the wiki site
(http://lua-users.org/wiki/SciteScripts) too. HTH.
ZapEOLs = function()
-- prep start, end positions, selection-capable
local selBeg, selEnd = editor.Anchor, editor.CurrentPos
if selBeg == selEnd then selBeg, selEnd = 0, editor.Length end
if selBeg > selEnd then selBeg, selEnd = selEnd, selBeg end
-- avoid making changes if no EOLs found
local sel = editor:textrange(selBeg, selEnd)
if not string.find(sel, "[\r\n]") then return end
-- perform substitution
editor:BeginUndoAction()
sel = string.gsub(sel, "[\r\n]", "")
editor.TargetStart = selBeg
editor.TargetEnd = selEnd
editor:ReplaceTarget(sel)
editor:EndUndoAction()
end
--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia
_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest