This is a dummy project greatly inspired by vi(m) to help me learn the ncurses
library for building interactive terminal applications.
This project is still extremely young and pretty buggy, it's more so an experiment rather than to serve as full-fledged software (vim already exists, afterall).
- Writing past 255 characters on a line exhibits some odd behaviour - this case is not properly handled
- There is no wrapping if writing past the width of your terminal - technically the line is still written correctly but visually is akward
ttedit
does not currently support dynamically resizing your terminal window, so zooming in/out will break the rendering
ttedit.demo.4.mp4
Simply use ttedit myfile.c
to open the editor. If file does not exist, it will create a new blank one. If file exists, it will read the contents and populate the buffer.
This is a typical cmake project, you can clone the repo, create a build folder inside and cmake .. && make
which will create a ttedit
executable inside src/
folder within your build folder.
There are two modes, VISUAL and EDIT. VISUAL mode allows you to move the cursor around and execute quick commands like deleting lines, jumping blocks, etc. EDIT mode is for writing text to the buffer (screen). By default, ttedit
starts you in VISUAL mode. Each set of commands will be broken out by their respective modes.
ESC
- go back to VISUAL mode
ESC
- clear the command buffer (e.g., if you started typing a number to jump lines but want to cancel, you can pressESC
to clear the buffer and write a different number)i
(insert) - enter EDIT mode
h
- move cursor leftl
- move cursor rightk
- move cursor upj
- move cursor down
s
(save) - Save the contents of the buffer into the fileq
(quit) - Exit the editor without saving (WARNING, IT WILL NOT ASK YOU IF YOU WANT TO SAVE FIRST AFTER MAKING CHANGES)
p
(prepend) - move to first non-space character and toggle EDIT modea
(append) - move to end of buffer and toggle EDIT moded
(delete) - delete the current linen
(newline) - create new line under cursor and jump to it in EDIT modeshift + h
(highlight) - Start highlighting text. Pressshift + h
again orESC
to cancel highlightingshift + c
(copy) - Copy highlighted textshift + p
(paste) - Paste copied text at current cursor position
b
(bottom) - jump to bottom of visual buffer (no scrolling)shift + b
(bottom) - jump to bottom of entire buffer (scrolling if needed)t
(top) - jump to top of visual buffer (no scrolling)shift + t
(top) - jump to top of entire buffer (scrolling if needed){X}j
(jump) - jump to lineX
(e.g.,23j
will jump to line 23)w
(word) - jump forward one wordshift + w
(word) - jump backward one wordshift + j
(jump) - jump forward/backward a scope:{
to}
or(
to)
and vice versa.