Skip to content
st4ckriftPublic

About

a vim-lite terminal editor in C++ — raw mode, VT100 rendering, search, zero dependencies

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ngl-Edit

a terminal text editor i built from scratch in C++. no frameworks, uses some libraries, and a whole lot of debugging at 2am.

C++ Platform License ngl-Edit screenshot

what it does

  • opens and edits files directly in your terminal
  • full keyboard navigation (arrow keys, obviously)
  • type, backspace, enter — works like you'd expect
  • Ctrl-S to save, Ctrl-Q to quit
  • Ctrl-F to 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

how to build and run

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.txt

to edit a new file that doesn't exist yet:

./editor newfile.txt

keybindings

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

what's actually going on under the hood

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.


known issues

  • first line display offset bug on some WSL terminal configs (tracked in #1)

built with

  • C++17
  • termios.h for raw terminal mode
  • sys/ioctl.h for terminal size detection
  • std::vector<std::string> for file contents
  • vim-style rendering because why not

why i built this

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

About

a vim-lite terminal editor in C++ — raw mode, VT100 rendering, search, zero dependencies

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages