OR: Reinventing a (crappier) Vi(m)
This is a post about my new text editing program yvi.
I like reinventing wheels. At least I do when it comes to making things like art , craft, food, or code. It’s how I learn. And it’s how I can shape tools or work to fit my own mind. I think because my background is in art, and because I didn’t formally learn Computer Science, despite the fact that I teach it, my software has a bit of a handmade feel to it.
As a case in point, I’ve built my own static website creator panblog when I grew frustrated with other more well-known alternatives that were clunky, poorly documented, or bloated pieces of software.
I’m also drawn to programming languages and paradigms that are a bit out of step with the mainstream and especially silicon valley’s current conception of software. For example, I love glue languages, languages and libraries for learners, and am a fan of scripting languages. My favorites are Lua, Bash, Fish, Forth-likes and BASIC.
Last year I spent a couple months researching and writing BASIC, specifically the Yabasic dialect, which is about a quarter century old and continously maintained. While I’ve been recommended by online friends to try out some other variants, I’ve found it easy to use and well-documented. It’s not the greatest for building graphical user interfaces, at least in my experience, but I use L5, or Processing-p5 libraries for that.
For a modern BASIC, it’s quite fun to use. I made my own cyber-hoss racing game , a command line game inspired by the UFO50 and Flash game Quibble Race. I also tinkered with the internals of the text version of The Oregon Trail, and built a clone, a simple version of Dope Wars economic simulation game.
Recently I came across The People’s Permacomputer, a project by Vidak, which led me to the online home for a great active BASIC Programming forum and various linked projects to build a 1970s style computer from scratch. I’ve been using Neovim (and before that, Vim) for years and years. I’ve never made a text editor before. But I decided it could be fun to try to implement my own. Vi seemed like a tall order to implement, but I’ve been using Offpunk, a small simple (arguable what this means) TUI client for browsing the internet including the world wide web and Gemini protocol. It has just a few implemented shortcuts like h/j/kl and g and G and others for moving around. So inspired by this, I thought I could likely build an ULTRA simple editor with a mininum of Vim commands. How hard could it be?
Well, it wasn’t too hard! With Yabasic in a hundred lines of code or so I quickly implemented the basic layout of a minimal blank page and added in those simple Vi commands for moving around and switching between insert and normal modes. I added the ability to open a file or start a new one. And to save. This was satisfying as I was now able to open the actual code for my vi.bas program and poke around and edit it. An early decision I made was what to do about wrapping. I decided to not have it as that simplified my program. As a compromise, you can write as much as you want on a line, but it only displays up to 80 chars, and in the status line at the bottom it shows your line number and character number.

So that become more usable. But then I wanted to be able to navigate forward and backwards by words, ending, jump to the beginning or end of a line, in addition to program start (‘gg’) and end, ‘G’. I also wanted the ability to delete a line with ‘dd’ so I added in multiple characters, the ability to compose commands together, add number combinations (only 1 - 9 currently), a search feature, and the scope of the program grew to about 500 lines. I added ‘u’ for most recent edit/line undo.
Later I added many more commands like ‘S’ (overwrite line), ‘c’ (cut and insert), and more. And I’ve put it to good use, working on coding projects and as a text editor for my writing. This post itself is written in the yvi editor.
At this point, I’m not sure where I should stop, and the program may still continue to evolve, but it’s hit a pretty good point and is usable now. Certainly there are a variety of bugs, and I don’t recommend it for anything important or that would be catastrophic if lost! I’m writing this in yvi itself, and the program seems to have the features implemented that I need to feel useful. I’m proud I’ve built my own text editor, that works well for basic writing and simple programs, and that can be extended.
It may not be beautiful code, but it’s functional and easily alterable. It’s not only the best Vi clone I’ve found written in a BASIC implementation, I think it’s the only one!
You can try it out today.