Making Minimalist Text Editor in C on Linux

  Рет қаралды 47,343

Nir Lichtman

Nir Lichtman

6 ай бұрын

Making a Minimalist Text Editor using C Library calls on Linux
You can view the code I wrote in the video over here: gist.github.com/nir9/6398b692...

Пікірлер: 105
@emirbrkic6649
@emirbrkic6649 5 ай бұрын
We need more chanel like this : C, Linux and vim, without an intro only pure clean code
@enderman4
@enderman4 5 ай бұрын
Linux (wsl2)
@mhm6421
@mhm6421 5 ай бұрын
​@@enderman4still is linux
@TheLukasBer
@TheLukasBer 5 ай бұрын
Check tsoding daily. Awesome channel with similar characteristics.
@phitc4242
@phitc4242 5 ай бұрын
I swear I'm on the verge of doing this, but I'm not thaz good as he is lmao
@MBrieger
@MBrieger 5 ай бұрын
Seriously, I am 58 years old and learned UNIX and C way back when. The Author needs to get some typing skills. There are more errors than actual Code.
@alangamer50
@alangamer50 5 ай бұрын
No Intro, no context, no nothing, he just jumped straight to the code and I love that. This was really useful and I literally just found out about the man command
@yuyuyuyuyuy484
@yuyuyuyuyuy484 5 ай бұрын
No intro, only keyboard sounds and simple explanations. Love it.
@Cromwell224
@Cromwell224 Күн бұрын
Well hey, it's supposed to be minimalist right
@rogerwinright2290
@rogerwinright2290 5 ай бұрын
Your channel is probably my new favorite programming channel. Quick to the delivery and gives good tips and tricks along the way!
@debajyatidey9468
@debajyatidey9468 4 ай бұрын
Finally found a channel where I can know & learn practical applications of C. Ig this channel is a blessing for me.
@tech477
@tech477 3 ай бұрын
Thank you for not wasting our time with useless talking. Raw, basic, straight to the point - fantastic channel.
@nyzss
@nyzss 5 ай бұрын
I’m learning C and these tutorials are a blessing, thank you very much for the content. If there was one thing I’d like very much is maybe longer and more in depth tutorials.
@snowpirate2652
@snowpirate2652 5 ай бұрын
This looks really cool! I tried the web server example you showed which worked really well and helped me to learn a little more about C, so I'm looking forward to giving this a try when I can. Please keep posting these great vids!
@themannyzaur
@themannyzaur 5 ай бұрын
This is fantastic! Glad I found your channel
@JotaDevelopment
@JotaDevelopment 5 ай бұрын
Everything in this channel is so good. I'm currently learning C, just because I have time enought to learn, and this kind of videos help me a lot. Cheers, Nir!
@fuzzy-02
@fuzzy-02 3 ай бұрын
I loved the commentary and showing manual while writing the code without over explaining things as if everyone watching isn't at least a basic programmer. Basics provided and the rest for us. Thank you!
@starc0w
@starc0w 5 ай бұрын
Very cool channel, really great!🍀Thank you very much! Small note about the code: If you read in 1024 bytes with fread, which is exactly the size of your buffer, you run the risk of overwriting the 0-termination of buffer (as soon as the file is larger than or equal to 1024 bytes). This means UB with printf("%s", buffer).
@nirlichtman
@nirlichtman 5 ай бұрын
Thanks :) that is a good point! when reading strings, it is a good practice to read one less than the buffer length into the zeroed buffer to avoid this issue. Remember that as I mentioned in the beginning of the vid, the code is just for fun and not for production
@hermessantos181
@hermessantos181 5 ай бұрын
Bro, your channel is exactly what i was searching, your videos are amazing, thank you for sharing it
@wispysparks
@wispysparks 5 ай бұрын
Engaging, straight to the point, keep up the good work man!
@animeshsarkar295
@animeshsarkar295 5 ай бұрын
I like the teaching style. Thank you Sir for providing useful contents
@theoriginalneckbeard
@theoriginalneckbeard 5 ай бұрын
Such a great channel. Without all that cringy clickbaiting, without all those cringy thumbnails. Just great content. Keep it up!
@john.darksoul
@john.darksoul 5 ай бұрын
You make writing code in C seem enjoyable :D
@rafaeloledo
@rafaeloledo 5 ай бұрын
this is the type of channel i wish i was watching on my first days of programming :)
@siddharthbisht1287
@siddharthbisht1287 5 ай бұрын
thank you, this is really cool❤❤❤
@wojciechd2135
@wojciechd2135 5 ай бұрын
Very good Video, straight to the point 👍.
@cursedfox4942
@cursedfox4942 5 ай бұрын
That’s beyond minimalist and a lot of code for something so simple
@hakonh3252
@hakonh3252 5 ай бұрын
It is fine to ignore error handling and stuff like that for toy examples, but consider showing or at least mention the bounds checked versions of the string manipulation functions. The old ANSI versions are basically deprecated as they are too dangerous to be used in actual production code.
@zeektm1762
@zeektm1762 5 ай бұрын
What alternative for low level I/O do you recommend?
@Mike-gs7eo
@Mike-gs7eo 5 ай бұрын
strncpy over strcpy for example. The n variants of these routines require a size parameter used to bound access. @@zeektm1762
@hakonh3252
@hakonh3252 5 ай бұрын
@@zeektm1762 I didn't say anything about I/O. I'm talking about string manipulation, like strncpy, strncmp, memchr.
@user-ed1nw6vr8n
@user-ed1nw6vr8n 5 ай бұрын
@@hakonh3252 so what alternative for those functions? Can you explain more
@johnshaw6702
@johnshaw6702 5 ай бұрын
​@@user-ed1nw6vr8nThe functions he is using are fine under these known circumstances. If you don't know the string source, then you should use stricter methods. Today that means functions like strcpy_s, that require specifying the maximum length of the acceptable string. Thus avoiding buffer overruns. You can easily craft your own methods of avoiding such issues, I did just that for many years. Its only necessary in cases that you are not in full control of the data you are processing or if you are creating a library, which, by definition, means you're not in control of its usage. When I first started programming, I gave my personal guarantee that my code would not crash the system, because I validated and tested everything. I, of course, didn't guarantee against hardware or memory failure, which was out of my control. Then Windows came out I couldn't guarantee anything, because my code was dependent on Windows and it's drivers, which was totally outside my control.
@sollybrown8217
@sollybrown8217 5 ай бұрын
Good video. Like the stb small libs in c one.
@dailydoseofshtposts6891
@dailydoseofshtposts6891 5 ай бұрын
Bro youre so underrated, i just found about you yesterday and i was fascinated, you have superb potential!
@foxmoss_
@foxmoss_ 5 ай бұрын
these vid have been making me use the man pages more :)
@Maagiicc
@Maagiicc 5 ай бұрын
This is gonna be the next vim 😳
@SimGunther
@SimGunther 5 ай бұрын
More like ed: The "official" UNIX text editor 😅
@razvandedu5285
@razvandedu5285 5 ай бұрын
Dude is coding without autocomplete... crazy!
@ullaskunder
@ullaskunder 5 ай бұрын
I wish I hadn't give up C
@SimGunther
@SimGunther 5 ай бұрын
It's never too late to pick it back up :)
@byronhambly
@byronhambly 5 ай бұрын
Hey, just found your channel, subbed! Small suggestion: why not split the screen vertically instead of horizontally?
@bity-bite
@bity-bite 5 ай бұрын
he can read more stuff if it's split horizontally
@slendi9623
@slendi9623 5 ай бұрын
@@bity-bite disagreed
@nirlichtman
@nirlichtman 5 ай бұрын
That's a good suggestion I actually mostly use horizontal split for some reason but I should definitely use vertical more especially for code with short lines, thanks!
@byronhambly
@byronhambly 5 ай бұрын
@@nirlichtman fair enough for your workflow! I agree that with shortish lines and a landscape screen, vertical split would work better for your videos. All the best and happy hacking!
@antonw8134
@antonw8134 5 ай бұрын
If you liked this video, you may also like the kilo text editor. Do a search and enjoy!
@liquidmobius
@liquidmobius 5 ай бұрын
I like your style, straight to the manpages. A real pro
@prebenskill
@prebenskill 5 ай бұрын
Take my sub!
@littlecurrybread
@littlecurrybread 5 ай бұрын
It would be fun if you tackled one of the c projects at codecrafters like the bittorrent clone
@arnabbanik6403
@arnabbanik6403 5 ай бұрын
wow nice
@bartholomewjoyce
@bartholomewjoyce 5 ай бұрын
Okay, add syntax highlighting and this can be my main editor
@nirlichtman
@nirlichtman 5 ай бұрын
Hmm, interesting idea for another video :)
@therealnotanerd
@therealnotanerd 5 ай бұрын
It may look good, but your editor has no syntax highlighting. Just kidding 🙂. It was awesome. The last time I developed in c was a few decades ago and it is nice to see these "basic" videos. Maybe I will start developing in C again for fun. And your channel will be a valuable resource. Thanks.
@miguelnto
@miguelnto 5 ай бұрын
That's kinda how the text editor "ed" works.
@Mike-gs7eo
@Mike-gs7eo 5 ай бұрын
Cool vid but this is super dangerous code. Strcpy should almost never be used. What happens if you edit a file here with a line longer than 1024 bytes :)
@juanchole1184
@juanchole1184 5 ай бұрын
Why strcopy is dangerous?
@Mike-gs7eo
@Mike-gs7eo 5 ай бұрын
@@juanchole1184 Strcpy does not take a length parameter and will keep copying bytes to the destination until it encounters a NULL byte in the source string. If the source is larger than the destination, then it will overflow which can lead to exploitable memory corruption
@nirlichtman
@nirlichtman 5 ай бұрын
The code is just for fun and not for production (as the disclaimer in the beginning of the vid) so I skip many additional checks besides the strcpy case :) If I would have written this for actual production use I would handle this by adding a check for the lengths before calling strcpy to make sure it would not overflow
@zombie_pigdragon
@zombie_pigdragon 5 ай бұрын
@@nirlichtman It would have been nice if (maybe even in editing) you'd added a disclaimer when writing particularly dangerous code, since there's a high risk people won't know what's safe/dangerous to write and will blindly copy the (entertaining, btw) video they've seen online.
@abiiranathan
@abiiranathan 5 ай бұрын
No nonsense coding! No fluff
@mrx2586
@mrx2586 5 ай бұрын
How did you split the terminal into both a text editor and a CLI within the same tab? and how are you switching between them?
@nirlichtman
@nirlichtman 5 ай бұрын
I am using the window splitting feature of Vim which is very powerful, for more information check out my video about window splitting on my playlist "Vim Tips"
@TheWinnieston
@TheWinnieston 5 ай бұрын
Thanks so much! Time to port this to 8080 assembly and put it on my retro computers! And then I can add any feature I want! *EDIT* I already added a simple command parser so you can insert, delete, edit lines and type out the file from any line number. ED here I come!
@TickerDev
@TickerDev 4 ай бұрын
אין עליך אח, מטורף!
@nirlichtman
@nirlichtman 4 ай бұрын
תודה!
@TickerDev
@TickerDev 4 ай бұрын
@@nirlichtman אין אני יזהה ישראלי ממרחקים 👀
@nirlichtman
@nirlichtman 4 ай бұрын
@@TickerDev 😂
@Tordek
@Tordek 4 ай бұрын
I understand this is a toy so the lack of error checking and such is fine, however one bad practice you really should cure yourself of is the preventative initialization of variables. When you ask for the line number, you do: int line = 0; scanf("%d", &line); Initializing line is unnecessary - it will be immediately overwritten - but it's a bad practice because by initializing it to "some" value you prevent the compiler from letting you know about any uninitialized accesses. It's preferrable to leave the variable uninitialized. Similarly with initializing the buffer: If I'd forgotten about null-termination, I'd much rather see data changing on every run (hinting at uninitialized access) than stuff appearing to run correctly. Also, a small detail: main _must_ return int. Returning void is an error.
@nirlichtman
@nirlichtman 4 ай бұрын
Thanks for the feedback, those are good points 👍 About the last point, main can actually also return "void" since C99 according to the C standard (in which case the exit code of the program will be undefined): devdocs.io/c/language/main_function
@Tordek
@Tordek 4 ай бұрын
@@nirlichtman Good to see some evolution in the language match usage. Nice video! Your channel looks fun.
@jazzyBSD
@jazzyBSD 4 ай бұрын
great! it's like ed
@exvimmer
@exvimmer 5 ай бұрын
Noice
@AggamRahamim-fs2zm
@AggamRahamim-fs2zm 5 ай бұрын
is this windows + WSL? terminal looks like that how'd you get a tiling wm?
@nirlichtman
@nirlichtman 5 ай бұрын
Yes, more info on welcome link on the channel description :)
@AggamRahamim-fs2zm
@AggamRahamim-fs2zm 5 ай бұрын
@@nirlichtman אגב האנגלית שלך מעולה, בדכ לא שומעים ישראלים עם כזה מבטא
@nirlichtman
@nirlichtman 5 ай бұрын
@@AggamRahamim-fs2zmתודה! אני במקור מארצות הברית :)
@AggamRahamim-fs2zm
@AggamRahamim-fs2zm 5 ай бұрын
אה אוקי חחח הגיוני@@nirlichtman
@antontheyeeter
@antontheyeeter 5 ай бұрын
why was main void?
@andrewliu6592
@andrewliu6592 5 ай бұрын
because that's a thing that c allows
@yashwanth8269
@yashwanth8269 5 ай бұрын
link for github repo?
@nirlichtman
@nirlichtman 5 ай бұрын
Added to the description :)
@ryuen-vn8em
@ryuen-vn8em 5 ай бұрын
Hi,I occasionally figured out that you can press Caps lock + k at the name of any function in your code and the man page of this function will be opened ,Maybe it will be useful for somebody
@cookedpotato
@cookedpotato 5 ай бұрын
With lsp extensions on nvim you can even do a hover like that of vscode. Also you can use the :Man to open a man page in split screen in vim or nvim , incase anyone wated to know too
@BlueBerryXD
@BlueBerryXD Ай бұрын
I'm going crazy, or is this man running a windows vm that is running ubuntu? Vm inspection?
@nirlichtman
@nirlichtman Ай бұрын
Windows 10 with WSL
@BlueBerryXD
@BlueBerryXD Ай бұрын
@@nirlichtman But it looks like you are running windows terminal inside of dwm? Or is it just for the lols?
@nirlichtman
@nirlichtman Ай бұрын
@@BlueBerryXD in this video I used a port of dwm for Windows called dwm-win32, since then I have stopped using dwm-win32 and started using a new twm I am working on called LightWM (due to many bugs in dwm-win32)
@furiousmilk6559
@furiousmilk6559 Ай бұрын
you sound like mark zuc
@TecnocraciaLTDA
@TecnocraciaLTDA 4 ай бұрын
lol, you just made a very basic version of ed
@king1king2king3
@king1king2king3 2 ай бұрын
Your videos are perfect but there's one exception the code editor that you use frustrates me and doesn't encourage me to continue the video. I think everything will be fine if you use a modern code editor.
@nirlichtman
@nirlichtman 2 ай бұрын
Thanks! Reason I use Vim is that it is my favorite code editor, coming to it after using IDEs, I decided 4 years ago to learn it properly and started really liking it and switched to using it as my main editor. Except my videos which are specific about Vim (which are mostly my early content), it should be easy to follow using other editors since the focus of these videos is about the programming.
@jcen_
@jcen_ Ай бұрын
​@@nirlichtmanVim is awesome, I switched from vscode to neovim about half a year ago and I'm never going back unless I end up working with something like java/c# which from my experience pretty much require an IDE. Other than that I've been doing some Go and C recently and neovim works great with them. And don't even get me started on the infinite customization possibilities.
@arupde6320
@arupde6320 5 ай бұрын
be regular .
@ElPikacupacabra
@ElPikacupacabra 5 ай бұрын
`void main` .... : |
@broggl
@broggl 5 ай бұрын
using vim to write a text editor lmao
Making Minimalist HTTPS Client in C on Linux
9:12
Nir Lichtman
Рет қаралды 11 М.
the cleanest feature in C that you've probably never heard of
8:13
Low Level Learning
Рет қаралды 123 М.
Can You Draw The PERFECT Circle?
00:57
Stokes Twins
Рет қаралды 83 МЛН
How I prepare to meet the brothers Mbappé.. 🙈 @KylianMbappe
00:17
Celine Dept
Рет қаралды 29 МЛН
КАХА и Джин 2
00:36
К-Media
Рет қаралды 2,6 МЛН
Making Simple Graphical Linux Distro from Scratch
17:19
Nir Lichtman
Рет қаралды 48 М.
Making Minimalist Hex Editor in C on Linux
9:35
Nir Lichtman
Рет қаралды 10 М.
The Importance of Error Handling in C
8:18
Nir Lichtman
Рет қаралды 28 М.
You don't need libraries to write a game engine in C++ | OpenGL | Devlog
2:50
Making a Very Minimal Windows Executable in C
7:48
Nir Lichtman
Рет қаралды 75 М.
Arenas, strings and Scuffed Templates in C
12:28
VoxelRifts
Рет қаралды 72 М.
Diving into Windows Keyboard Driver
10:29
Nir Lichtman
Рет қаралды 20 М.
i wrote my own memory allocator in C to prove a point
5:23
Low Level Learning
Рет қаралды 337 М.
Coding My Own Text Editor Again (Ded S02E01)
1:49:37
Tsoding Daily
Рет қаралды 89 М.
I tried Unraid for the FIRST time in 2024
21:05
Techno Tim
Рет қаралды 59 М.
How much charging is in your phone right now? 📱➡️ 🔋VS 🪫
0:11
Introducing GPT-4o
26:13
OpenAI
Рет қаралды 4,3 МЛН
Добавления ключа в домофон ДомРу
0:18
3D printed Nintendo Switch Game Carousel
0:14
Bambu Lab
Рет қаралды 4,2 МЛН
iPhone 15 Pro vs Samsung s24🤣 #shorts
0:10
Tech Tonics
Рет қаралды 6 МЛН