a terminal text editor i built from scratch in C++. no frameworks, uses some libraries, and a whole lot of debugging at 2am.
- opens and edits files directly in your terminal
- full keyboard navigation (arrow keys, obviously)
- type, backspace, enter — works like you'd expect
Ctrl-Sto save,Ctrl-Qto quitCtrl-Fto search (jumps to first match + highlights it)- status bar showing filename, line count, and cursor position
- scrolls through files of any size
- vim-style
~for empty lines because we respect the culture
you need g++ and make. if you're on Windows, use WSL.
git clone https://github.com/stackrift1511/ngl-Edit.git
cd ngl-Edit
make
./editor yourfile.txtto edit a new file that doesn't exist yet:
./editor newfile.txt| key | what it does |
|---|---|
| arrow keys | move cursor |
Ctrl-S |
save file |
Ctrl-Q |
quit |
Ctrl-F |
search (Enter to confirm, Esc to cancel) |
Backspace |
delete character |
Enter |
new line |
this isn't just a school project with cin and cout. here's what i actually had to figure out:
raw terminal mode — by default your terminal buffers input line by line and echoes everything you type. for a text editor that's useless. i had to manually disable this using termios and talk directly to the terminal driver via POSIX system calls (tcgetattr, tcsetattr).
VT100 escape sequences — to clear the screen, move the cursor, or highlight text, you write specific byte sequences like \x1b[2J or \x1b[7m directly to stdout. this is how every terminal application (vim, htop, etc.) works underneath.
RAII for terminal cleanup — if the program crashes while in raw mode, your terminal stays broken. i used a C++ class with a destructor to guarantee the original terminal settings are always restored, even on crash. this is the RAII pattern and it's one of the most important ideas in C++.
rendering loop — every keypress triggers a full screen redraw. clear screen → draw all visible lines → draw status bar → position cursor. this keeps the display consistent without having to track what changed.
scrolling — the editor tracks a rowoff (row offset) — how many lines you've scrolled past. screen row i always maps to file line i + rowoff. when the cursor moves outside the visible window, rowoff adjusts.
- first line display offset bug on some WSL terminal configs (tracked in #1)
- C++17
termios.hfor raw terminal modesys/ioctl.hfor terminal size detectionstd::vector<std::string>for file contents- vim-style rendering because why not
wanted to actually understand how terminal applications work at the byte level — not just use ncurses and call it a day. turns out there's a whole world of escape codes and terminal state management that most people never see. worth it.
built by stackrift._.15
