This project is a minimalistic Vim-inspired text editor implemented in C, using the ncurses library for terminal-based rendering.
- Command, Insert, and Visual Modes:
- Command mode for navigation and commands.
- Insert mode for editing text.
- Visual mode for selecting and copying text.
- Undo/Redo Stack: Unlimited undo and redo operations within the defined history limit.
- Text Navigation: Cursor movement across lines and columns.
- File Operations:
- Load a file when starting the editor.
- Save changes back to the file.
- Clipboard Support:
- Copy selected text in visual mode.
- Paste clipboard contents.
Ensure you have the following installed:
- GCC (GNU Compiler Collection)
ncurseslibrary
To compile the project, run:
gcc -o ink ink.c -lncursesThis command compiles the vim_editor.c source file and links it with the ncurses library.
Run the compiled binary:
./ink [filename]- If a
filenameis provided, the file will be loaded into the editor. If not, a blank buffer is opened.
q- Quit the editors- Save the file
i- Enter insert modev- Enter visual modeEsc- Exit insert or visual mode, returning to command mode
h- Move cursor leftj- Move cursor downk- Move cursor upl- Move cursor right
u- Undo the last actionr- Redo the last undone actiony- Copy selected text in visual modep- Paste clipboard contentsBackspace- Delete the character before the cursorEnter- Insert a new line
- Start by pressing
vin command mode. - Use navigation keys (
h,j,k,l) to select text. - Press
yto copy the selection.
- After copying text in visual mode, press
pin command mode to paste the contents at the cursor's position.
- TextBuffer: Manages the text being edited, including line lengths and cursor positions.
- Undo/Redo System: Tracks changes to allow reversing or reapplying edits.
- File I/O:
loadFile(): Loads the contents of a file into the editor.saveFile(): Saves the current buffer to a file.
- Rendering: Displays the text buffer in the terminal with line numbers and mode indicators.
insertChar(): Inserts a character at the current cursor position.deleteChar(): Deletes the character before the cursor.undo()andredo(): Manage the history of edits.render(): Refreshes the screen to reflect changes.
ncurses: Used for terminal rendering and handling user input.