geany-plugin-sort.lua
No OneTemporary

File Metadata

Created
Thu, Mar 12, 6:07 PM

geany-plugin-sort.lua

function split(str, pat)
local t = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end
geany.select(0, geany.length())
local text = geany.selection()
local lines = split(text, " ")
table.sort(lines)
local output = table.concat(lines, "\n")
geany.selection(output)

Event Timeline