10 ms·
Writing my own text editor, and daily-driving it
- shablulman 7mo ago[flagged]
- codazoda 7mo agoI use my own text editor too. Nobody else seems to get value from it. I’m still surprised by the value we get from home grown solutions.
- willrshansen 7mo agoDidn't even link it. :(
- mbrezu 7mo agoI guess the "link" is the implicit suggestion to write your own :-)
- altilunium 7mo agoI use my own text editor too. Sometimes I get surprise questions from my friends whenever they see my screen. “What’s that?” “That’s my own text editor!”
- hnlmorg 7mo agoI’m currently writing my own text editor (it’s basically a markdown equivalent of Jupyter notebooks). I’ve also written my own terminal emulator and my own shell. The shell does actually see other contributors and users these days too.
- lenkite 7mo agoYou can perform a legitimate muscle-flex when saying that too.
- fjfaase 7mo agoI use my own editor too. I modified an existing editor to my own needs. But I do use VSC as well for multi file projects. My editor can load images as well and has a scripting language to manipulate images. I primarily use it to edit my website, which is a static website in bare HTML. It also has some 'browser' functions in the sense that F5 opens a link including jumping to an anker if there is one in the link. It does have colour coding for HTML that also checks for matching tags.
- marckerbiquet 7mo agoI use my own text editor too, written using my own programming language. Fortunately Operating Systems suit my needs and I won't have to write my own OS ;-)
- zacklee-aud 7mo ago[dead]
- willrshansen 7mo agoThis feels like two steps up from a highly customized vim config. But I want one step up. I want to be able to piece together an editor from modular task specific executables. Different programs for file searching, input mapping, buffer modification and display, etc. Probably similar to how LSPs are already separated from most editors. One step less hardcore than writing a whole editor. Anyone know of any existing projects along these lines?
- piekvorst 7mo agoAcme [1] It steps back from the “customize everything” mantra, believing that approach leaves users with an underdeveloped essential system. But it still has two major APIs: one for window manipulation [2], the other for text-based integration with the surrounding system via plumber [3]. All textual CLI tools (that is, those without pseudographics) work by default and are the heart of its style. I use Acme for everything except web browsing (although most links are still managed by Acme). [1]: http://youtu.be/dP1xVpMPn8M http://youtu.be/dP1xVpMPn8M [2]: http://9p.io/magic/man2html/4/acme http://9p.io/magic/man2html/4/acme [3]: http://9p.io/sys/doc/plumb.html http://9p.io/sys/doc/plumb.html
- topaz0 7mo agoYou can already do this in vim. Pretty easy to shell out to whatever command you want and use the result for various purposes.
- willrshansen 7mo agoThat's still built on top of the hardcoded vim design choices though. For example, I really like the "select then edit" approach of Helix, but Vim doesn't really play nice with that (there may be better plugins since I last looked to be fair). File handling, buffer rendering, and frames have very little to do with that, and yet I have to switch editors, lose all my plugins and configurations, and switch all those subsystems at once. There's missed opportunities for modularization. Edit: looks like Neovim is already split from its UI.
- 7mo ago
- abktowa 7mo agoShould make my own text editor. Would make for an interesting project at least.
- mudkipdev 7mo agoI would recommend using the ropey crate for easy performance gains. A string buffer is quick to implement but you will hit a wall as soon as you need to edit large files.
- mizmar 7mo agoIt's not that bad. You need really large files to notice. The largest realistic file I'll ever touch - sqlite3 amalgamation with 270k lines and 9.1 kB - still takes only 6 ms to memmove it on my poor laptop. Any regular up-to 10k lines file is memmoved in order of microseconds.
- sampullman 7mo agoThat's true for code editing, but it's nice to not have to reach for a different solution when editing huge files. Sometimes I like to open up big log files, JSON test data, etc.
- oneeyedpigeon 7mo agoDo you actually edit big log files?
- spongebobstoes 7mo agoI interactively pare down log files to just the parts I need. I rarely save the result
- mejutoco 7mo agoI am always surprised even vim chokes on files with one massive line. That could be a useful optimization too.
- zesterer 7mo agoYes, absolutely. I've since switched to rope-backed buffers, but I don't think the rope itself is actually adding much from a performance standpoint, even for really very large files. We talk about big-O complexity a lot when talking about things like this, but modern machines are scarily good at copying around enormous linear buffers of data. Shifting even hundreds of megabytes of text might not even be visible in your benchmark profiling, if done right. When benchmarking, I discovered that the `to_pos`/`to_coord` functions, which translate between buffer byte positions and screen coordinates, were by far the heaviest operation. I could have solved that problem entirely simply by maintaining a list of line offsets and binary-searching through it.
- whynotmaybe 7mo agoFond memory of when I wrote an editor in the 90's because we didn't want to use "ms edit" for COBOL and asm files. Syntax coloring, fast buffering and even a screen saver. You could even call the compiler directly from it. All this running on a pentium 120 and it felt a thousands times faster than today's vscode. But vscode can edit multiple files at the same time...
- fragmede 7mo agoFiring up VSCode on an old laptop, and having it get totally bogged down running a text editor killed a part of my soul. I'm from the vim era of computing, but I have a hard time telling people that's the route to go today with today's tools.
- b00ty4breakfast 7mo agoClassic electron app. vscode is no doubt a powerful tool but it and other apps in the modern milieu are the software equivalent of those big lifted trucks that like to "roll coal" and get like 5mpg highway.
- mghackerlady 7mo agoWhoever decided to write a text editor in JavaScript and HTML/CSS for any reason other than absolute necessity deserves to be taken out back and shot
- nurettin 7mo ago> But vscode can edit multiple files at the same time borland turbo pascal and turbo c could also open multiple files at the same time.
- mghackerlady 7mo agoIf you're creative with it ed can as well
- whynotmaybe 7mo agoYes, my point was that my homemade editor didn't...
- mllev15 7mo agoJosh Barretto is the genius behind the Super Mario 64 GBA port. I would gladly use his editor.
- sira04 7mo agoLove his SM64 videos. Link to the latest one for anyone who's curious: https://www.youtube.com/watch?v=nS5rj80L-pk https://www.youtube.com/watch?v=nS5rj80L-pk
- bananaboy 7mo agoI love this! The line “resist the urge to push the difficult bits off to a box of statistics” particularly resonated with me!
- givemeethekeys 7mo agoI smell money burning.
- croisillon 7mo agoon iPhone Safari i don't get the grey middle background layer, only dark text on dark background
- zesterer 7mo agoThat's odd, I've not heard that reported by anybody else. If I get time I'll look into it.
- fay_ 7mo ago[dead]
- priowise 7mo ago[flagged]
- zesterer 7mo agoAuthor here. Off the top of my head: - Software is simpler than you think when you boil it down. There's a massive incentive to over-sell the complexity of the problem a solution is trying to solve, to pull in users. This is true both for proprietary products and, to a lesser degree, FOSS. You can probably replace most of the tools you use day-to-day in a weekend or two - provided you keep practising the art of just building stuff. I'm not saying that you should, but it's worth keeping in the back of your head if a tool is driving you mad. - You can achieve 80% of the functionality with 20% of the work required to build an off-the-shelf solution. In a surprising number of cases, you can do the same with 20% of the integration cost of an off-the-shelf solution. A lot of software is - to put it quite bluntly - shit (I include a lot of my own libraries in this list!). There are probably only a few hundred really valuable reusable software components out there. - Aggressively chase simplicity and avoid modularity if you want to actually achieve anything. The absolute best way to never get anything useful out of a project is to start off by splitting it into a dozen components/crates/repositories. You will waste 75% of your time babysitting the interfaces between the components rather than making the thing work. - Delete code, often. If you look at the repo activity (https://git.jsbarretto.com/zesterer/zte/activity/code-frequency https://git.jsbarretto.com/zesterer/zte/activity/code-freque...) you'll see that I'm deleting code almost as much as I'm adding it, especially now that I've got the core nailed down. This is not wasted effort: your first whack at solving a problem is usually filled with blunders so favour throwaway code that's small enough to keep in your head when the time comes to bin it and make it better. - It is absolutely critical that you understand the fundamental mode of operation of the code you've already written if you want to maintain development velocity. As Peter Naur said, programming is theory-building and the most important aspect of a program is the ineffable model of it you hold in your head. Every other effort must be in deference to maintaining the mental model.
- alansaber 7mo agoCouldn't agree more with this. Particularly re simplicity and deleting depricatsd code.
- genie3io 7mo ago[dead]
- osmsucks 7mo agoI, too, mourn the death of Howl. It was a quirky yet surprisingly "comfortable" editor. But I am now at home with Helix and Flow Control.
- doom2 7mo agoWhen do you choose one over the other?
- osmsucks 7mo agoHelix is my default, as it's a more mature/stable editor. I fire up Flow Control from time to time to follow how it's developing and for more casual editing. They both do an excellent job overall, but my muscle memory binds me to Helix for now. (I know Flow Control provides Helix keybindings, but I haven't tried that yet and I generally like to retain the default behavior of an editor so that my user experience is more "portable" across machines.)
- greatgib 7mo agoOne of the best kept secret and one that he should have tried is "Kate". Good old style editor that is a native app, not an electron app. All the features that you might want and more, but simple and efficient. And the most important for me, super snappy. I can't bear the latency that you get for typing code when using things like vscode. I don't know how people can appreciate that.
- hresvelgr 7mo agoI'm quite partial to Zed. Very snappy, and you can turn off all the AI features globally if you like.
- anta40 7mo agoYes, I'm happy with Zed a Sublime replacement, usually for general text-editing. For coding, I'm still stuck with VSCode and nvim.
- deleted 7mo ago[deleted]
- lionkor 7mo agoZed is fantastic for Rust, C, C++, and similar languages. I wouldn't bother using it for Web things like HTML, Js, CSS, because it simply isn't better at that than VSCode. Same goes for C# -- as a Microslop technology, you're better off using Microslop tooling.
- FireInsight 7mo agoI don't find Zed much worse for working with webtech either.
- bigstrat2003 7mo agoZed is a no go in my book until they learn to respect their users and stop installing third party software* without asking. Completely unacceptable practice, and their reason of "most people will want LSPs to be there without effort" doesn't cut it. * nodejs specifically, but it wouldn't be ok no matter what the software was. It's my computer, not yours, don't download and run stuff without getting permission.
- piker 7mo ago> Cursor manipulation is difficult! When you’re using a text input widget, much of the behaviour you expect as table-stakes isn’t something you’re even conscious of. Exactly what happens when you hold a keybinding like ctrl + shift + left is probably muscle memory but the logic required to getting it all playing together nicely is not fun to write. This is so true. And there are a lot of other cases where we just expect the OS or library to do it for us. Instead, we have to reimplement the wheel. Of course if understanding the wheel is part of the goal, then that works, but if you’re venture-backed good luck justifying the use of time to your investors. This is why Electron’s gravity is so strong.
- zesterer 7mo agoThat is certainly true! If your target is end users, use the off the shelf solution that has been inspected by many eyeballs. The best part of building tools for yourself or a small community of people is that you only need to cover the relatively tiny subset of functionality that you actually use.
- kleiba 7mo agoThere's a reason Emacs and vi have been around for decades. They're good.
- ivanjermakov 7mo agoMaybe not good, but tenacious. Once you have a muscle memory, it's rarely worth the effort to switch.
- Narishma 7mo agoNo, they're good. Otherwise new people wouldn't be learning and using them.
- deleted 7mo ago[deleted]
- keyle 7mo agoThe editor: https://git.jsbarretto.com/zesterer/zte https://git.jsbarretto.com/zesterer/zte
- alansaber 7mo agoWould like to see someone make their own WYSIWYG editor.
- ivanjermakov 7mo agoMaking something highly custom usually contradicts WYSIWYG ideas. Same reason why advanced users use hotkeys instead of toolbars.
- eludwig 7mo agoI actually did this back in the late 90s! The editor was called "Scorpio"[1]. It was written for the classic MacOS in some version of C with objects, maybe Think C(?). I'm not 100% sure. It's an amazing fun thing to do, but I probaby wouldn't wan't to do it again now. This thing didn't handle unicode (I had never heard of it), barely handled spell checking and didn't handle bi-directional input. Text (1 byte per char) was stored in a big array on the heap. Styles were also an array (again on the heap) of fixed length structs. Font information, in the form of fixed-point width tables, was gathered from system calls and cached. It did actually support inline pictures though, which was pretty challenging. Writing an editor is a hugely fun project. Highly recommended. [1] https://atpm.com/3.03/page11.shtml https://atpm.com/3.03/page11.shtml
- dizhn 7mo agoIt's so fascinating how different things people look for in such a simple thing as a text editor. A file browser? Terminal?
- mghackerlady 7mo agothere's a reason Unix like systems usually ship with 3 or so
- embedding-shape 7mo agoIndeed, all I need is something that connect to a running background repl so I can evaluate code, everything else basically bells and whistles. Others seem to run entire OSes as their editor. I'm glad we have so many options, and it seems like each year we have even more options :)
- catapart 7mo agoAny chance people in this thread have some recommendations for text-editing libraries? I would love to build my own text editor, to do some things in my own way that no one else seems to have an interest in doing, but one of the big things for me is that it must be a GUI. I won't bore people with the reasons, but that requirement forces me to bring along a lot of stuff, like a font renderer (at least one) and a graphics context. To do all of that and write a text editing library at the same time is a little more than my nights and weekends can handle. If I start on just the text editor, it'll only work in a terminal console, so I won't actually use it for my own projects. If I start on just the GUI, I won't actually use it because it won't actually work. So, even if I'm going to replace the text editing library at the heart of the project with custom code, eventually, it's pretty much a non-starter if I don't have something to use to get started. To be honest, I'm kind of surprised to have so much trouble finding a solution here. Everything I find is either a self-contained text editor, or a full-on "mission statement" GUI (development can be easier/better by using our editor's features). I've had a very hard time finding something that is just an API that I can feed input and have it return me reasonable state updates about the text content. CRDTs or whatever. I'm assuming people just figure you're either going to write a toy text editor, in which case simple text editing will work, or you're going to write a full-blown showcase product, in which case your advanced structural design with performance-focused editing, language servers, multi-cursor support, etc, will be your selling point and functional focus. But that seems to leave this surprising hole where a developer who wanted to "rebuild windows' Notepad app, except that it can handle text files with massive lines without slowing way down" would have to actually implement the advanced text editing line management rather than just use a library for this well-solved problem.
- kryptiskt 7mo agoSeveral of the lean GUI text editors are built on Scintilla (https://scintilla.org/ https://scintilla.org/), which provides a cross-platform editing component that can be integrated in GTK, Windows or Mac GUI apps. Maybe that has too much bells and whistles for you, since it's both about editing and presentation.
- catapart 7mo ago
- ivanjermakov 7mo agoI went the same path of writing a text editor from scratch. There are a lot of moving parts, so I tried to outsource as much features as possible - LSP for intellisense, tree-sitter for highlighting and syntax-aware features, fzf for search and file handling, etc. I also tried to design it so that it can be tweaked to one's needs with simple code changes, suckless-style. It was indeed a pain using it for the first few weeks, where every 5 minutes I found some bug and had to go back and fix it, instead of steadily working on some other project. Good news is more bugs you fix, less bugs is left. https://github.com/ivanjermakov/hat https://github.com/ivanjermakov/hat
- zesterer 7mo agoNice work! And yes, that gradual acceleration of productivity where your fixes and tweaks from the past compound on your ability to get things done in the future is a great feeling.
- octoclaw 7mo ago[dead]
- entaloneralie 7mo agoThis was so nice to read, I've been trying to encourage my friends to write their own editors, there's something really nice about the process of working within your own tool. I've used my own text editor(it's call Left) for nearly 10 years, it took time to get it just right, but I iterated over the years(using Left to edit Left) but that time I spent putting it together is paid back 20x by the joy it gives me opening it and working in it in the morning. I'd do it all over again if I had to.
- pklausler 7mo agoI'm 19 years into using my own ("aoeui"), and it's one of the best things I ever did for my own productivity.
- entaloneralie 7mo agohell yeah that's awesome, I wish I had that insight when I was your age so I didn't waste my time editor hoping for 5 years.
- pklausler 7mo agoI'm curious, how old do you think I am?
- entaloneralie 7mo agoOh damn, I very much misread your message as "I'm 19 and using my own-" Yeah, okay you have 10 years of dogfooding ahead of me X) Sorry. Still, goals.
- rkomorn 7mo agoThey could've started writing it in the womb. I don't think you were categorically wrong...
- chambored 7mo ago
- busterarm 7mo agoAs someone who deals with remote servers all day, vi(m) is a must.
- Jeffrin-dev 7mo ago[flagged]
- gorjusborg 7mo agoI laughed out loud when the author wrote 'it replaced nano'. So you are claiming to have tried dozens of editors, discarded them, only to land on nano as your daily driver? If that's true, this person must be a character.
- gammalost 7mo agoNo, the author used Howl for their normal work and Nano occasionally. I would guess when working in the terminal
- lpribis 7mo agoHe implied replacing nano was the first step, before using it for more complex (software development) tasks. First use it just for quick one-off edits of /etc/blah.conf then graduate to using it for longer editing sessions.
- zesterer 7mo agoNo, nano is not my daily driver. It's what I use when I want to quickly edit a file with root access because, funnily enough, I'm not in the habit of running my primary editor with superuser permissions :) Nano is a low-hanging fruit that was the first of many tools I gradually massaged the editor into replacing.
- jonjacky 7mo ago"There is an old saying: Once in your life you should build a house, plant a tree, and write an editor. I decided to start with the last one. ..." from Vip - Vi-Style Editor in PicoLisp https://picolisp.com/wiki/?vip https://picolisp.com/wiki/?vip
- newzino 7mo ago[flagged]
- mdonahoe 7mo agoI had fun re-implementing antirez's "kilo" editor https://github.com/antirez/kilo https://github.com/antirez/kilo There's a nice tutorial for it https://viewsourcecode.org/snaptoken/kilo/ https://viewsourcecode.org/snaptoken/kilo/ Great way to learn more about terminal modes and write some raw C
- MomsAVoxell 7mo agoI’m a bit partial to antirez’ LOAD81 editor, myself .. https://github.com/antirez/LOAD81 https://github.com/antirez/LOAD81 .. but that’s mostly because LOAD81 is just fully great as well .. I’ll have to dig into kilo a bit and see how antirez’ two editors compare with each other ..