r/cprogramming • u/radio_hx • Apr 13 '26
Tx - Small, C text editor
Hi all!
Recently been working on a personal project to improve my C programming skills. From initially following the Kilo text editor project, I decided to grow the editor into a modal, vim - like editor. I had a lot of fun doing this project and learned a lot! Would love some feedback and any thoughts or opinions.
Thanks!
20
Upvotes
3
u/DaCurse0 Apr 14 '26
you don't have to initialize every field individually in main.c to 0, you can just do
E = {0}, which technically only initializes the first element to zero, but the C spec guarantees that omitted fields in this syntax will also be initialized to 0 so the entire struct will be initialized to zero2
u/HaskellLisp_green Apr 15 '26
Are contributions allowed?
2
u/zhivago Apr 16 '26
As usual, I recommend writing some test cases -- you can do this by writing up something like main.c called foo_test.c, compiling it, and executing it to check the exit code.
2
u/zhivago Apr 16 '26
I'd also suggest investing in some more efficient data structures.
This is going to get slow pretty fast.
One very simple technique that you might want to check out is the 'gap buffer'.
1
u/po1k Apr 14 '26
Great stuff. Problems: The cli input arg, the write file