Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Save eXide editor tabs to disk
xquery version "3.1";
# Save eXide editor tabs to disk
1. Install "LocalStorage Manager" Chrome extension
2. Open eXide. Reload to force eXide to write all editor tabs to local storage.
3. Click on "LocalStorage Manager" extension icon in Chrome toolbar
4. Select "Download". This saves a file like localhost_8080-2019-12-31_15-55-06.txt to your Downloads folder.
5. Paste the file's full path into the $local:eXide-storage-file variable (preserving the "file:/" protocol)
6. Update the $local:destination-directory variable with your desired destination
7. Run the query in eXide. All tabs will be stored to the destination directory, stripping off the "/db" prefix. New files will be stored in the "new" directory with a basename "untitled-", followed by a number taken from the tab name, followed by an extension based on the mimetype.
declare variable $local:eXide-storage-file {
declare variable $local:destination-directory {
declare variable $local:eXide-storage {
let $tabs :=
for $key-g in map:keys($local:eXide-storage)
group by $tab-key := $key-g => replace("^(eXide\.\d+).+$", "$1")
where matches($tab-key, "^eXide\.\d+$")
order by substring-after($tab-key, ".") => xs:integer()
(: name, data, mime, last-line, writable, path :)
map:entry("tab", $tab-key),
for $key in $key-g
let $label := substring-after($key, $tab-key || ".")
map:entry($label, $local:eXide-storage($key))
let $destination :=
|| "/eXide-export-"
|| $local:eXide-storage-file
=> substring-after("localhost_8080-")
=> substring-before(".txt")
for $tab in $tabs
let $extension :=
switch ($tab?mime)
case "application/xquery" return ".xq"
case "application/xml" return ".xml"
default return ".txt"
let $is-new := starts-with($tab?path, "__new__")
let $path :=
if ($is-new) then
$tab?path => replace("^/db/", "") => substring-before($tab?name)
let $filename :=
if ($is-new) then
replace($tab?path, "__new__", "untitled-") || $extension
where $tab?data ne ""
file:mkdirs($destination || "/" || $path),
file:serialize-binary($tab?data => util:string-to-binary(), $destination || "/" || $path || "/" || $filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment