This is a series of blog posts that shows you how to build a text editor in Rust. It’s a re-implementation of kilo in Rust, as outlined in this fantastic tutorial. Same as the original booklet, these blog posts guide you through all the steps to build a basic text editor,
You will almost always be able to see your changes in action by applying the changes, saving and running the program. I will explain every step along the way as best as I can - sometimes in great detail, and often linking to other pages. Feel free to skim over the prose and ignore the links, there is plenty to learn just by applying the code changes and watching your text editor grow!
That’s why I started to learn Rust, and I have reimplemented
kilo is complex enough to pose a challenge, and when I read it, I wished it was available for Rust - and now it is!
And why the name?
hecto follows more modest goals than
kilo. It does not aim to be small, and it wasn’t even my own idea - so it seemed appropriate to give it a more modest name than its spiritual precedessor.
kilowas distributed under the BSD-2 Clause License
- The original tutorial was distributed under CC BY 4.0
hectoand this tutorial are licensed under CC BY 4.0
Indication of Changes
While these blog posts are based firmly on the original tutorial, the code has been adapted to Rust, not only by calling the closest “rust counterpart function”, but by trying to solve things “the rust way”. Similarily, all explanations have been checked and revised, and in many cases heavily rewritten, in the context of Rust. Therefore, this tutorial should be seen as a “rust remix” of the original
I’m happy that you read my work and would love to hear from you - especially if you are either stuck or have found a better way to solve specific things. Keep in mind that this is mostly an exercise for me to get to know Rust - so if there’s a better way to do things, please reach out!
Table of Contents
- Reading User Input
- Raw User Input and Output
- A Text Viewer
- A Text Editor
- Syntax Highlighting