TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Kilo: A text editor in less than 1000 LOC with syntax highlight and search

222 pointsby klaussilveira10 days ago

14 comments

akkartik10 days ago
Funny story: using kilo was the final straw [1] in getting me to give up on terminals. These days I try to do all my programming atop a simple canvas I can draw pixels on.<p>Here&#x27;s the text editor I use all the time these days (and base lots of forks off of): <a href="https:&#x2F;&#x2F;git.sr.ht&#x2F;~akkartik&#x2F;text2.love" rel="nofollow">https:&#x2F;&#x2F;git.sr.ht&#x2F;~akkartik&#x2F;text2.love</a>. 1200 LoC, proportional font, word-wrap, scrolling, clipboard, unlimited undo. Can edit Moby Dick.<p>[1] <a href="https:&#x2F;&#x2F;git.sr.ht&#x2F;~akkartik&#x2F;teliva" rel="nofollow">https:&#x2F;&#x2F;git.sr.ht&#x2F;~akkartik&#x2F;teliva</a>
评论 #44038434 未加载
评论 #44041838 未加载
评论 #44038229 未加载
评论 #44042894 未加载
lor_louis10 days ago
Kilo is a fun weekend project, but I learned the hard way that it&#x27;s not a good base uppon which you should build your own text editor.<p>The core data structure (array of lines) just isn&#x27;t that well suited to more complex operations.<p>Anyway here&#x27;s what I built: <a href="https:&#x2F;&#x2F;github.com&#x2F;lorlouis&#x2F;cedit">https:&#x2F;&#x2F;github.com&#x2F;lorlouis&#x2F;cedit</a><p>If I were to do it again I&#x27;d use a piece table[1]. The VS code folks wrote a fantastic blog post about it some time ago[2].<p>[1] <a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Piece_table" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Piece_table</a> [2] <a href="https:&#x2F;&#x2F;code.visualstudio.com&#x2F;blogs&#x2F;2018&#x2F;03&#x2F;23&#x2F;text-buffer-reimplementation" rel="nofollow">https:&#x2F;&#x2F;code.visualstudio.com&#x2F;blogs&#x2F;2018&#x2F;03&#x2F;23&#x2F;text-buffer-r...</a>
评论 #44040211 未加载
评论 #44037512 未加载
评论 #44038635 未加载
thomasdziedzic10 days ago
How timely, I just finished going through a tutorial that builds a text editor like kilo from scratch: <a href="https:&#x2F;&#x2F;viewsourcecode.org&#x2F;snaptoken&#x2F;kilo&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;viewsourcecode.org&#x2F;snaptoken&#x2F;kilo&#x2F;index.html</a><p>Would highly recommend the tutorial as it is really well done.
评论 #44040482 未加载
评论 #44036989 未加载
评论 #44040971 未加载
90s_dev10 days ago
Reading through this code is a veritable rite of passage. You learn how C works, how text editors work, how VT codes work, how syntax highlighting works, how find works, and how little code it really takes to make <i>anything</i> when you strip away almost all conveniences, edge cases, and error handling.
giancarlostoro9 days ago
I made a similar editor using Lazarus... since it has syntax highlighting components... I guess that&#x27;s cheating. The more I think about it though, I wonder if Freepascal could produce a nice GUI for Neovim.<p>I did try to build one in Qt in C++ years ago, stopped at trying to figure out how to add Syntax Highlighting since I&#x27;m not really that much into C++. Pivoted it to work like Notepad so I was still happy with how it wound up.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;Giancarlos&#x2F;qNotePad">https:&#x2F;&#x2F;github.com&#x2F;Giancarlos&#x2F;qNotePad</a>
nulld3v10 days ago
It also inspired this similar Rust project: <a href="https:&#x2F;&#x2F;github.com&#x2F;ilai-deutel&#x2F;kibi#comparison-with-kilo">https:&#x2F;&#x2F;github.com&#x2F;ilai-deutel&#x2F;kibi#comparison-with-kilo</a><p>Although it does cheat a bit in an effort to better handle Unicode:<p>&gt; unicode-width is used to determine the displayed width of Unicode characters. Unfortunately, there is no way around it: the unicode character width table is 230 lines long.
评论 #44037282 未加载
评论 #44036664 未加载
anonzzzies9 days ago
Ah darn. Closing in on retirement (will never happen, coding is too much fun for profit or charity) age, I resistent building an editor but I want to. Need to. I hacked so much vim, emacs, eclipse, vs code and its all crap (the newer, the worse: all these useless gimmicks you won&#x27;t use past grade school aaarrr while lacking power user features). Can I do better? This seems a good start.
lbj9 days ago
Funny. These days when I see a headline like that, I assume it&#x27;s some type of web component.<p>Why are all the commenters so eager to get out of terminals?
JdeBP9 days ago
One interesting thing is that even some of those 1000 lines could have been eliminated.<p>It duplicates the C library&#x27;s cfmakeraw() function, for instance.<p><a href="https:&#x2F;&#x2F;man.freebsd.org&#x2F;cgi&#x2F;man.cgi?query=cfmakeraw&amp;sektion=3" rel="nofollow">https:&#x2F;&#x2F;man.freebsd.org&#x2F;cgi&#x2F;man.cgi?query=cfmakeraw&amp;sektion=...</a>
nodesocket9 days ago
This seems like a great alternative for Nano; though Nano is really good and just works.
jonstewart10 days ago
ed is the standard text editor.
revskill9 days ago
So a text editor is about grid manipulation ?
fuzztester10 days ago
on first look, the name sounds heavy, but the product actually turns out to be very light.<p>go <i>figure</i>.<p>;)
cies9 days ago
Last serious work on this was in 2020. Lacks news worthiness imho.
评论 #44042863 未加载
评论 #44048303 未加载