Write All Keywords to Text File

This is a snippet that exports a list of all keywords encountered in the currently loaded library to a text file. Hierarchical keywords will be written with “>” as the hierarchy delimiter.

// Write All Keywords to Text File

var lines = []
collect_keywords = function(kwds, prefix) {
	kwds.forEach(function(kw) {
		lines.push(prefix + kw.keyword())
		collect_keywords(kw.children(), prefix + kw.keyword() + " > ")
	})
}
collect_keywords(library.rootNode().keywords(), "")
lines.sort()
var text = ""
for (i in lines) text += lines[i] + "\n"

var path = chooseFile({
	save: true,
	formats: [{
		name: "Text Files",
		patterns: ["*.txt"]
	}]})
if (path != "")
	writeFileUTF8(path, text)

Installation

  1. Copy the snippet source code above to the clipboard
  2. In Aspect, go to the “Snippets” page of the settings dialog and click “Add Snippet…”
  3. Paste the source code into the “Source Code” area - the “Menu Entry” field will be filled out automatically

The new menu entry should now be visible in the “File” menu and you can also optionally assign a keyboard shortcut in the “Shortcuts” section of the settings dialog.