Discovered a new text editor: micro - modern, small, written in Golang (2024-03-03)

A person introduced me to micro today.

The micro text editor was created by Zachary Yedidia back in 2016. Micro is designed to be accessible for those coming from Nano, but it is also appealing to Vim users looking for easily configurable options. Micro has sensible defaults, has full mouse support uses very familiar Ctrl-key shortcuts. The editor supports syntax highlighting and is extensible through plugins.

Online sources claim that: “The rise in its popularity can also be linked to the growing trend of developers looking for lightweight, efficient tools that do not have the steep learning curve of some other editors while still offering powerful features.”

The editor stores the contents of the file in a [][]byte buffer.
There is the Line primitive:

// A Line contains the data in bytes as well as a highlight state, match
// and a flag for whether the highlighting needs to be updated
type Line struct {
	data []byte

	state       highlight.State
	match       highlight.LineMatch
	rehighlight bool
	lock        sync.Mutex

	// The search states for the line, used for highlighting of search matches,
	// separately from the syntax highlighting.
	// A map is used because the line array may be shared between multiple buffers
	// (multiple instances of the same file opened in different edit panes)
	// which have distinct searches, so in the general case there are multiple
	// searches per a line, one search per a Buffer containing this line.
	search map[*Buffer]*searchState
}

And then the LineArray collection of lines:

// A LineArray simply stores and array of lines and makes it easy to insert
// and delete in it
type LineArray struct {
	lines    []Line
	Endings  FileFormat
	initsize uint64
}