1
0
Fork
You've already forked cog
0
cog is a simple line ed-like text editor written in C, readapted to be begginer friendly and easy to use.
  • C 73.5%
  • Makefile 26.5%
Find a file
2026年05月24日 16:55:00 -03:00
img Add COG banner image and edit .gitignore to exclude test files 2025年07月09日 19:26:48 -03:00
src ADD [VERSION 1.0]: New changes and improves on cog text editior (and bug fixes) 2026年05月24日 16:55:00 -03:00
.gitignore Add COG banner image and edit .gitignore to exclude test files 2025年07月09日 19:26:48 -03:00
LICENSE ADD [VERSION 1.0]: New changes and improves on cog text editior (and bug fixes) 2026年05月24日 16:55:00 -03:00
Makefile ADD [VERSION 1.0]: New changes and improves on cog text editior (and bug fixes) 2026年05月24日 16:55:00 -03:00
README.md ADD [VERSION 1.0]: New changes and improves on cog text editior (and bug fixes) 2026年05月24日 16:55:00 -03:00

cog preview

cog is a minimalist line-based text editor implemented in C, inspired by classic editors like ed. It enables basic text file editing in a terminal environment using simple commands.

Features:

  • Load existing text files or create new files by default.

  • Append, delete, and navigate text lines interactively.

  • Save changes back to disk.

  • Switch between command mode and insert mode.

  • Execute shell commands prefixed with bsh$.

  • Basic terminal control with ANSI escape codes.

Build:

Use the provided Makefile or compile directly with gcc:

$ make all

Useful Makefile targets:

$ make help
$ make check
$ make debug
$ make run
$ make clean
$ gcc src/main.c -o cog

To install system-wide (optional):

$ sudo make install

To uninstall:

$ sudo make uninstall

To android devices, run the command: (Make sure you have gcc and make installed on your device before run it)

$ make android

Usage:

Run the editor optionally with a filename argument:

$ cog <filename.txt>

If no filename is provided, the editor uses/creates a default file named foo._.

Commands:

a — Enter insert mode to append new lines. End insert mode by typing a single dot . on a new line.

m — Modify the current line, removing the old line and replacing a new line insert.

p — Print the current line.

n — Print the current line with its line number.

P — Print all lines without line numbers; current line prefixed with *.

N — Print all lines with line numbers; current line prefixed with *.

+ — Move cursor to the next line.

- — Move cursor to the previous line.

l.<NUMBER> — Move cursor to the specified line number (e.g., l.5).

d — Delete the current line.

w — Save the buffer to the current file.

clear — Clear the terminal screen.

bsh$ <COMMAND> — Execute a shell command from within the editor.

h — Show command help.

q — Quit the editor.

Technical Details:

  • The editor uses an array of dynamically allocated strings to store text lines.

  • Limits: up to 1000 lines, each line up to 256 characters (adjustable).

  • Terminal cursor and screen management via ANSI escape sequences.

  • Simple command-line interface for interaction.

  • No external dependencies besides the standard C library.

Compatibility:

cog is compatible with Windows, Linux, MacOS and general Unix systems. Android systems are included to full compatibility on version 0.3.