Counting lines and characters in .js with bash wc -lm


#1

It’s good to see that the FoldingText node tree and the command line wc -lm take the same view of how many lines and characters there are in a document.

Very useful when concatenating several files for a FoldingText CLI overview - makes it possible to link back from the filtered report to a particular file and line (or even offset into the line).

FWIW the FT .js analogue of bash wc -lm filepath is something like:

function(editor) {
	var	tree = editor.tree(), 
		lngChars=tree.textLength(),
		lngLines=tree.nodeToLineNumber(tree.lastLineNode());

	return lngChars + ' characters, in ' + lngLines + ' lines.';
}