Categorygithub.com/alejandrosuero/goedit
repositorypackage
0.0.0-20240618104253-b98fdbfed9e1
Repository: https://github.com/alejandrosuero/goedit.git
Documentation: pkg.go.dev

# README

GoEdit - A bare bones text editor, written in Go

For this project I will be using termbox-go, a minimalistic API for text-based user interfaces.

My objective is to create a simple terminal based text editor, like vi, with the base functionality

Index:

Installation

To start using this editor, first thing you need is to install Go -> golang's official site.

Once Go is installed, go to your terminal clone this repository.

git clone https://github.com/AlejandroSuero/GoEdit

Note: If you don't have git installed, go to -> git's official site or select at the top where it is a green button that says "Code ▼" and next "Download ZIP".

Next, go into the directory where you have it cloned.

# This will initialize the project
go init goedit

# This will download the dependencies
go mod tidy

Finally, you can build the project and start using it.

# For UNIX users
go build -o goedit editor.go
./goedit <path-to-the-file-or-leave-it-empty-for-a-welcome-message>

# For Windows users
go build -o goedit.exe editor.go
.\goedit.exe <path-to-the-file-or-leave-it-empty-for-a-welcome-message>

For now, check the commands and GoEdit those files 🫡

Supported commands

These are the commands which are currently supported.

Note: Commands are case sensitive

Normal mode commands

CommandDescription
QExits the editor
!QForces the exit. (Useful if you don't want to write your changes)
wWrites file
iEnters insert mode one character before
IEnters insert mode at the beginning of the line
aEnters insert mode one character after
AEnters insert mode at the end of the line
oInserts a new line bellow the cursor and enters insert mode
OInserts a new line on top of the cursor and enters insert mode
j or ArrowDownMoves cursor down n times. Ex: If j is pressed it will move once, if 2 and then j are pressed it will move it twice. Any number is valid, and 2ArrowDown as well
k or ArrowUpMoves cursor up n times. Ex: If k is pressed it will move once, if 2 and then k are pressed it will move twice. Any number is valid, and 2ArrowUp as well
l or ArrowRightMoves cursor right n times. Ex: If l is pressed it will move once, if 2 and then l are pressed it will move twice. Any number is valid, and 2ArrowRight as well
h or ArrowLeftMoves cursor left n times. Ex: If h is pressed it will move once, if 2 and then h are pressed it will move twice. Any number is valid, and 2ArrowLeft as well
PageUpMoves the cursor half a page up
PageDownMoves the cursor half a page down
ggMoves the cursor to the beginning
GMoves the cursor to then end of the file

Insert mode commands

CommandDescription
<Esc> or <Ctrl>qExits insert mode
Basic interactionsWrite any character, insert spaces, tabs, delete characters and add new lines