# y: yobibyte's text editor

`y` is a highly opionated text editor written by yobibyte.
It started as following the [kilo](https://viewsourcecode.org/snaptoken/kilo/index.html) tutorial in Zig, but grew out in something bigger.
Somewhere along the way, I decided to simplify and ported the project to C before it was feature-complete.
The goal is to reimplement a subset of vim I use to do my work and switch from vim to y.

## Philosophy

**Radical simplicity**
I will not be overengineering this.
I will implement everything the dumbest way possible until I hit a performance or maintenance issue.
Every line of code is an enemy.
I will not be implementing features I do not need.
For instance, I do not need syntax highlighting, and I will not be implementing that.
I do not need to support every possible use-case or enable the community to modify the editor with a scripting language.
I do not need LSP support or anything similar.
I do not need a complicated build/release/CI system, everything should be local and fast.
This editor will not be configurable, if you want to use it, you will need to change the constants in the source code and rebuild.
This is also the reason I will not be supporting Windows and add if branches everywhere to do platform-dependent stuff.

**No dependencies**
I will implement everything from scratch. I will not be using any libraries apart from the standard library.
This is a great way to learn, but also makes me more robust.
Being self-reliant is a good thing

**Pacing yourself**
I do not have a PM asking me about new feature deadline.
I can use vim in the meantime, I am not in a rush.
I am here to have fun and learn.

## Roadmap
- [x] Text viewer chapter from the tutorial.
- [x] Text editor chapter from the tutorial.
- [x] Basic mode and motions support (normal/insert, hjkl).
- [x] Go to a line number with :<line number>.
- [x] Commenting out code with language-dependent comment chars.
- [x] Search chapter from the tutorial.
- [x] Visual mode. (now gone, I do not need it with marks)
- [x] Tab expansion, controlling tabwidth.
- [x] Multiple buffers.
- [x] Copy/Paste with internal registers.
- [x] Port project to C.
- [x] Undo.
- [x] Regex engine.
- [x] Search and Replace.
- [x] Macros

So long, and thanks for all the fish.

## Help

hjkl        you know what it is
<num>hjkl   you know what it is
i           Enter the insert mode, ESC to exit it.
a           Move cursor to the right and enter the insert mode.
o           Start a new line and enter the insert mode.
gg          go to the 0th line
G           go to the last line
<space>     open command prompt
u           undo
r           redo
m<char>     add a mark
v<char>     go to a mark line
V<char>     go to a mark position
ESC         stop the character command sequence (e.g. 10gESC will cancel those)
]           go to the next buffer
[           go to the prev buffer
0           move to the line start
$           move to the line end
c           comment/uncomment line
p           paste
w,b         move to next/prev word
s           save
/,f         search forward
?           search backward
n           continue previous search
q/Q         close buffer/force close buffer (do not show the 'modified' warning)
x,DEL       del character to the right
>>          shift line to the right
<<          shift line to the left
yy          copy a line
dd          del a line
de          del until the line end
yva/dva     copy/delete until a mark line
yVa/dVa     copy/delete until a mark position
>va         shift until the mark line to the right
<num>gg     go to line
<num>dd     delete next <num> line
<num>yy     copy next <num> line
%           if on a bracket, go to a matching one


Prompts:
:e<fname>   add a buffer
:bd         close buffer
:bd!        force close buffer
:bn/bp      next/prev buffer
:s/foo/bar  replace foo with bar in the text
:<num>      go to line

bd!         fore close buffer

