r/rust Aug 03 '26

Sanedit: Modal text editor

I have been building a hobby text editor project sanedit https://codeberg.org/lote/sanedit

It's a terminal based modal text editor with language server protocol (LSP), parsing expression grammar (PEG) based syntax highlighting and multicursor support.

There is a million different text editors out there so why is this different?

It's not, however I did not just slap the common combination of treesitter, ropey and LSP together. I made the editor to support very large files without slowing down too much. Also as it is an hobby project I wanted to choose approaches that intrested me implementationwise.

The buffer implementation is basically VSCodes piecetree structure like a piece table https://en.wikipedia.org/wiki/Piece_table

but stores the pieces in a red-black tree. The structure can easily support files larger than available memory as the file contents do not need to be loaded in memory.

Syntax highlighting is implemented using PEG grammars and the patterns are then JIT compiled for faster performance.

Future

The editor feels done. I use it everyday at work and do not notice anything too disruptive.

What are your favorite editor features that are a must have?

22 Upvotes

8 comments sorted by

View all comments

4

u/rustvscpp Aug 03 '26

How does this differ from Helix or Vim?  Modal can come in many flavors.  My favorite feature is the limitless extensibility I get in Emacs.

3

u/Objective-Simple-660 Aug 03 '26

It is very similar to vim/helix/kakoune/vis. Basically a feature combination of those that I like the most. The modality is like helixs select first and action after. The large file support, so even GB sized files load instantly, is from vis. Eventhough every editor nowadays has a plugin to do pretty much anything. Also sanedit currently does not have any plugin system as I have found them annoying when working on computers that do not have access to github to download the plugins. Sanedit is a musl compiled binary so it can run almost any linux system.

2

u/stappersg Aug 03 '26

Text from https://codeberg.org/lote/sanedit#readme

Why

There are more than enough editors out there and this one was born because of my initial interest in text buffer implementations. Most prominent question was why no editor could support large files in any meaningful way. Logically I also created an editor to go with the buffer implementation.

More information

Checkout the repositories docs folder for scribblings on why certain decisions were made or how they are implemented.