Parchment is a Sparse, Spartan Text Editor
2024/Dec 17
This article follows a previous article on this site.
To be sparse means to be thinly scattered. In the context of software, sparseness would describe the sense than an app doesn’t have much going on. There is a minimal amount of information to show, and a minimal amount of interactivity.
To be spartan means to significantly restrict oneself, be it by forgoing nourishment or by prioritizing unpleasant tasks. For software, to be spartan might mean that the designers of an app intentionally omitted features which are seen as a necessity in other similar applications. This extreme application of minimalism usually serves a purpose to illustrate how certain features which are taken for granted may actually be counterproductive for most use cases.
I originally set out to write a new kind of integrated development environment (IDE) which can be reprogrammed as it’s used. My hypothesis at the time was that it’d be easier to write code if you could test parts of it live in the editor itself as you write it. I also wanted to provide a small interface to allow programmers to easily extend and reprogram the IDE as they use it.
Ultimately, I found myself becoming distracted by the features I’d built. Arbitrary code execution to manipulate my editor did not prove itself to be the force multiplier that I’d hoped, and so I pivoted toward a design that, as I continued to use it, stayed out of my way and had defaults that gave me the precise experience I sought. I began stripping anything that made it more difficult for me to get my work done, until I was left with something sparse and spartan.
As expected of any GUI text editor, Parchment features the basic file management functionality. Open a file saved on your computer, save when finished, “Save as” to save your work into a different file than what you started from. To make it easier to navigate the computer’s file system, there is also the ability to open the folder containing the currently focused file. Basic search and replace functionality is available, as is the ability to quickly move the cursor to any line in the current file. That second feature is very helpful for writing code alongside a live compiler which rebuilds my current project whenever a file is saved — if there’s an error in compilation, the exact line where it ocurred is printed out by the compiler and I can simply jump to it in Parchment by typing the line number.
The ability to jump to any line in a file by that line’s number replaces a ubiquitous feature in text editors aimed at programmers: the line number margin. Both features serve the same purpose; They allow the user to navigate a text file by line number, which is very useful for programmers. The difference is that the line number margin is always visible; It is information that the programmer rarely needs, yet which bombards her sight line at all times. So long as I can jump to any line by its number, I do not mind the line number margin’s absence.
Parchment lacks many other features which are standard for programmers. Indentation won’t be automatically inserted to new lines, making it more difficult to nest code deeply. Deeply nested code is a bad thing; It makes code less readable and is generally more complicated. To make it more difficult to nest code means the programmer will need to prioritize refactoring their logic into discrete units, which improves the readability and resilience of code. A lack of syntax highlighting means the user will need to actually understand the programming language they’re using; It encourages much more thoughtful work. I have also found that it’s easier to stay focused when my text isn’t flashing in various bright and vibrant colours.
Parchment also puts a limit to how wide its text editor component can be. Lines which are too long are difficult to read. It’s easy to lose your place in a paragraph composed of lines which are too long. Parchment limits the width of its text editor component so that lines are wrapped aggressively, so you don’t need to worry about it. This is soft wrapping as well, so if you need to go back to change earlier text, you won’t suddenly find yourself with a shorter or longer line in the middle of a paragraph. If you’re not a programmer, this might seem like an odd feature to highlight, but it’s something many plain text editors get very wrong. To make it easy to distinguish wrapped lines from those which have been manually broken with the “enter” key, some blank space is added between line breaks. The actual content of the text files I am working on have never been clearer to me than when I write in Parchment.
The above code is Parchment’s “replace all” function. Notice that the text of the comment after “begin_user_action()” is all bunched together; It is a long line which has been wrapped and thus gains the readability of being several short lines, yet visually is also clearly only a single unit of source code.
Parchment takes a few steps to assist the user in writing text files which won’t cause problems in other contexts. It refuses to open any file that isn’t text, and when saving files to disk it will fix them up in sensible ways by removing useless space characters at the end of lines and removing spurious line breaks at the end of the file. For consistency with other applications, it will instead always ensure that the last character in a file is a line break. When reading files, these trailing line breaks are ignored, so newly opened files won’t end in a blank line. It’s a strange detail to highlight, but this is a default I’ve never seen anywhere else. Parchment is the only text editor I am aware of which never demands that the user put in effort to actually adhere to longstanding conventions for plain text.
I’ve for a long time felt that plain text editing has lost its way. In the search for a solution I’ve not only used ubiquitous tools like Vim, I’ve also discovered and enjoyed ancient tech like Sam or Acme, and even a tiny home-brewed text editor which combined Vim with Acme to create a unique environment for piping text between command line applications. Each of these programs had significant flaws which turned me away from them. I put Parchment together specifically to avoid these problems, and my faded desire to use anything else tells me I’m on the right path.
There are still details to be ironed out before it can see a full release, but its source code is available on GitHub for those curious to see.