[Toybox] [PATCH] vi.c: Backspace to merge lines when at beginning, get_endline is no more, cleanup

enh enh at google.com
Thu Mar 7 12:27:33 PST 2024


(fwiw, i've had lots of "why isn't this more like vim?" complaints, and
this specific backspace behavior was one of them. i didn't know about this
myself either. like MS Word i suspect vim is one of those products where
everyone only uses 5%, but we all use a different 5%...)

On Thu, Mar 7, 2024, 12:23 Jarno Mäkipää <jmakip87 at gmail.com> wrote:

> On Thu, Mar 7, 2024 at 6:32 AM Oliver Webb via Toybox
> <toybox at lists.landley.net> wrote:
> >
> > Looking at vi.c again, (I _know_ I can write code better then I did in
> October, and
> > since the cleanup pass hasn't happened yet I thought I'd start improving
> things now)
> > noticed there was no support for merging lines when doing a backspace at
> the start
> > of a line (e.g. deleting blank lines by pressing backspace) So I added
> that. There
> > is a bug where it will delete the last character of the line you are
> merging into,
> > Still. That behavior is considerably better than nothing (And dunno how
> to debug it,
> > vi_join isn't doing it's job for some reason) so I added it into the
> patch.
>
> Well I am unsure what backspace should do on vi, I dont remember why I
> even added it. If i look vi man page there is no mention of backspace
> existing. I dont personally backspace except while typing on insert
> mode or ex mode and only the data I am about to insert not the data
> already inside buffer. Perhaps I added backspace delete for buffer
> stuff since someone request it on mailinglist, but cant find who,
> when, and why.
>
> If looking other vi clones by just using them, and comparing backspace
> behavior
>
> nvi does the thing how i originally intended, backspace can only be
> used to cut your typo out of your ongoing insert, not to delete stuff
> from buffer. and it does not move your cursor backward inside buffer
>
> vim on :set compatible; behaves almost same as nvi. it does not delete
> stuff from buffer but it allows you to move cursor left while in
> normal mode, but only up until newline
>
> vim on :set nocompatible deletes stuff from buffer if in insert mode,
> and goes backward on normal mode, but jumps into previous line
>
> busybox vi, has bit similar behavior as vim in compatible mode, but it
> has its own weirdness too (I backspaced around, press undo 2 times and
> it inserted some garbage into my open buffer. )
>
> 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?
>
> 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)
>
> 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.
>
>
> br
> Jarno
>
>
> >
> > As far as ex commands go, this patch removes the function get_endline,
> and replaces it with directly
> > probing the buffer. Which is much faster then redrawing the page 2 times.
> >
> > Other then that, This replaces a couple of variable names and removes a
> unnecessary goto
> >
> > -   Oliver Webb <aquahobbyist at proton.me>
> > _______________________________________________
> > Toybox mailing list
> > Toybox at lists.landley.net
> > http://lists.landley.net/listinfo.cgi/toybox-landley.net
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20240307/ae806165/attachment-0001.htm>


More information about the Toybox mailing list