[Toybox] [PATCH] vi.c: Backspace to merge lines when at beginning, get_endline is no more, cleanup
Oliver Webb
aquahobbyist at proton.me
Thu Mar 7 17:07:26 PST 2024
On Thursday, March 7th, 2024 at 14:23, Jarno Mäkipää <jmakip87 at gmail.com> wrote:
[...]
> Feel free to fix it up, some other features are simpler since you can
> just read the man page and make it behave accordingly, but backspace
> is maybe not very trivial one since its either you follow heirloom vi,
> or make some educated assumption how average person would want to use
> it. To me this patch is not necessarily fixing it, but making it
> behave the way you want, maybe more vim way?
The way most people use vi-like text editors today is with
vim (or one of it's many forks). The same way that people usually interact
with unix-like operating systems with linux. Making toybox vi act more
vim-like would it easier to use for 90% of vi users.
> About join lines function I dont see any issues with original version,
> its doing what it supposed to do, searching newline and taking it out,
> (with some buffer management magic called piece table method, here is
> some info if you interested on how it works
> https://www.cs.unm.edu/~crowley/papers/sds.pdf)
Vim does insert a space in the merged line, which is nice for formatting
and would fix the "deletion of last character" problem. Dunno how to implement
it yet without doing ugly stuff with run_vi_cmd() yet
> My original idea was to make vi as simple as possible: move with
> simple motions, delete, yank and push and insert few words with insert
> mode. Kinda rescue editor, in 1000 lines of code and leave it to Rob
> to clean up, (or yank out and rewrite.) Then people started using it,
> at least as rescue editor, so some quality of life patches came in,
> and now its near 2000 lines.
A minimal development environment needs at least a basic text editor.
I noticed while trying to do stuff with mkroot (Getting runtest.sh to run on it
so we can test commands like passwd (or nommu support assuming qemu has options for it)) That
vi didn't have any ex commands other then write and quit. Since batch processing
with ex commands is convenient (I know sed exists, but having it built in is more useful)
I tried (am trying) to implement some of them. And once you have ex commands, implementing ed
(and ex) are really easy (a for loop with run_ex_cmd()).
- Oliver Webb aquahobbyist at proton.me
More information about the Toybox
mailing list