1. 16
  1. 10

    This looks interesting. On a related note, if you want something closer to vi, but the lack of UTF-8 and bidirectional text in OpenVi is a problem, take a look at neatvi.

    1. 9

      I really enjoy everything the author of neatvi has written (neatroff especially). I reached out to him once via email basically to tell him I was a fan. He was very gracious.

      1. 3

        He was very gracious.

        Agreed. When neatvi was relatively new, I submitted a small number of patches and had several questions. He was always helpful.

      2. 5

        For UTF-8, another option is nvi. OpenBSD’s vi is actually an old version of nvi that lacks UTF-8 support.

        1. 3

          Don’t confuse OpenVi/OpenBSD-vi, nvi1, and nvi2. These are all different programs that share the same heritage.

          OpenVi is derived from OpenBSD vi, which derives from nvi version 1.79, released in 1996. There has been 25+ years of independent development as part of the OpenBSD base system and it has diverged greatly in that time, with the development going in a different direction.

          Nvi1, currently on version 1.8x, is maintained at https://repo.or.cz/nvi.git - I believe the latest version of this editor does have multibyte support, but this is not the OpenVi/OpenBSD version of the editor.

          Nvi2 shares the same heritage as well, but is also quite far removed from 1996 code. It is actively maintained at https://github.com/lichray/nvi2 and also includes multibyte support.

          (If I remember correctly) the multibyte support in both Nvi1 and Nvi2 derives from nvi-m17n, developed as part of the KAME project by the late itojun - http://www.itojun.org/itojun.html … the last update to nvi-m17n was about 3 years ago, and is available at https://cgit.freebsd.org/ports/tree/editors/nvi-m17n/files

          Currently, optimizing for size using link-time garbage collection with GCC 11.2 on an x86_64 glibc Linux system gives a good idea of the changes over time and the different direction these editors have taken. OpenVi is also simplified in structure and does not have the three levels of abstraction of Nvi 1.8x - there is no library interface layer.

          For OpenVi, the compiled binary is 278K, and for Nvi1 (nvi-1.81.6-45-g864873d3) the compiled binary is 528K (36K for vi, 528K for libvi).

          OpenVi has a single configuration standard with no dependencies beyond curses.

          Nvi1 has many options beyond trace/debug (“widechar” “gtk” “motif” “threads” “perl” “tcl” “db3/4” “internal-re”) - so at least 255 different build variations are possible.

          (I’ve not yet built Nvi2 myself on Linux so I can provide an actually fair comparison yet, but I will, and I’ll summarize the data in an FAQ section of the README)

          1. 2

            (Note that I was using the defaults here, I’m sure that it’s possible to trim down Nvi 1.8x further, but I’m comparing the default compilations, optimized for size (GCC, -Os, -fdata-sections, -ffunction-sections, link-time GC enabled), but Nvi 1.8x is a much more complicated program, and has a different feature set, and different supported options.

            1. 1

              Well, I allowed myself to omit the fact that OpenBSD’s vi has seen some independent development past nvi 1.79, which is true. A “(based on)” should be inserted before “an old version” in my original comment. But I appreciate the thorough summary of nvi versions!

            2. 2

              Nope, the vi in OpenBSD is nvi - you’re confusing it with nvi2. Both are in active development: nvi and nvi2.

              1. 2

                It should be noted that DragonFly BSD has imported nvi2, but with some modifications as well.

                It’s unfortunate there is so much confusion surrounding the various nvi-based editors, mostly due to them all being so similarly named.

                Part of why I chose to call this project OpenVi was because the name was - suprisingly - available, and does not directly imply that OpenVi is exactly Nvi1/2 or OpenBSD’s vi.

                (In particular, all bugs in OpenVi should be considered my fault.)

            3. 2

              I will confirm that Neatvi is an excellent project, but I’m a bit more interested in Nextvi - https://github.com/kyx0r/nextvi - the RTL/bidi in Neatvi is a huge strength and is done very cleanly when compared to other vi-likes

            4. 4

              Coincidentally, just yesterday I was looking through the code of a few vi implementations, because I’m writing a toy implementation based on the libvim idea of having a core that is a function of (editor_state, input) -> editor_state and decoupling it from the rendering. I hadn’t seen this implementation nor neatvi, so thank you!

              1. 2

                Nvi1 (https://repo.or.cz/nvi.git) provides you with just the kind of shared library interface I think you’re looking for, which is used for the different interfaces:

                36K    vi
                24K    vi-ipc
                108K   vi-motif
                492K   libvi.so.0.0.0
                660K   total
                

                OpenVi does not - it’s a single monolithic binary:

                278K   bin/vi
                
              2. 2

                (sorry for an HN cross-post, but this might also be helpful, to see the different options of the various Nvi forks [no Nvi2 here … yet])

                To give a quick overview of ‘:set’-able options (:set all output) of the various editors that derive from ‘nvi’…

                n-t-roff vi (01/14/2017) aka Heirloom Traditional ex/vi:

                noautoindent            nomodelines                     noshowmode
                autoprint               nonumber                        noslowopen
                noautowrite             open                            nosourceany
                nobeautify              nooptimize                      tabstop=8
                directory=/var/tmp      paragraphs=IPLPPPQPP LIpplpipbp taglength=0
                noedcompatible          prompt                          tags=tags /usr/lib/tags
                noerrorbells            noreadonly                      term=screen-256color
                noexrc                  redraw                          noterse
                flash                   remap                           timeout
                hardtabs=8              report=5                        ttytype=screen-256color
                noignorecase            scroll=17                       warn
                nolisp                  sections=NHSHH HUnhsh           window=35
                nolist                  shell=/usr/bin/zsh              wrapscan
                magic                   shiftwidth=8                    wrapmargin=0
                mesg                    noshowmatch                     nowriteany
                

                OpenVi 7.0.13-dev (02/20/2022):

                noaltwerase     noedcompatible  noimctrl        nooctal         nosecure        nottywerase
                noautoindent    escapetime=2    keytime=6       open            shiftwidth=8    noverbose
                autoprint       noerrorbells    noleftright     path=""         noshowmatch     novisibletab
                noautowrite     noexpandtab     lines=36        print=""        noshowmode      warn
                backup=""       noexrc          nolist          prompt          sidescroll=16   window=35
                nobeautify      noextended      lock            noreadonly      tabstop=8       nowindowname
                nobserase       filec=" "       magic           remap           taglength=0     wraplen=0
                cdpath=":"      noflash         matchtime=7     report=5        tags="tags"     wrapmargin=0
                cedit=""        hardtabs=0      mesg            noruler         noterse         wrapscan
                columns=108     noiclower       noprint=""      scroll=17       notildeop       nowriteany
                nocomment       noignorecase    nonumber        nosearchincr    timeout
                imkey="/?aioAIO"
                paragraphs="IPLPPPQPP LIpplpipbpBlBdPpLpIt"
                recdir="/var/tmp/vi.recover"
                sections="NHSHH HUnhshShSs"
                shell="/bin/zsh"
                shellmeta="~{[*?$`'"\"
                term="screen-256color"
                

                OpenBSD vi (7.0-current):

                noaltwerase     escapetime=1    noleftright     path=""         noshowmatch     warn
                noautoindent    noerrorbells    lines=36        print=""        noshowmode      window=35
                autoprint       noexpandtab     nolist          prompt          sidescroll=16   nowindowname
                noautowrite     noexrc          lock            noreadonly      tabstop=8       wraplen=0
                backup=""       noextended      magic           remap           taglength=0     wrapmargin=0
                nobeautify      filec=" "       matchtime=7     report=5        tags="tags"     wrapscan
                cdpath=":"      noflash         mesg            noruler         noterse         nowriteany
                cedit=""        hardtabs=0      noprint=""      scroll=17       notildeop
                columns=108     noiclower       nonumber        nosearchincr    timeout
                nocomment       noignorecase    nooctal         nosecure        nottywerase
                noedcompatible  keytime=6       open            shiftwidth=8    noverbose
                paragraphs="IPLPPPQPP LIpplpipbpBlBdPpLpIt"
                recdir="/tmp/vi.recover"
                sections="NHSHH HUnhshShSs"
                shell="/usr/local/bin/zsh"
                shellmeta="~{[*?$`'"\"
                term="screen-256color"
                

                nvi-1.81.6-45-g864873d3 (2022-02-21) aka Nvi1:

                noaltwerase     escapetime=1    nolisp          optimize        shiftwidth=8    nottywerase
                noautoindent    noerrorbells    nolist          path=""         noshowmatch     noverbose
                autoprint       noexrc          lock            print=""        noshowmode      warn
                noautowrite     noextended      magic           prompt          sidescroll=16   window=35
                backup=""       filec=""        matchtime=7     noreadonly      noslowopen      nowindowname
                nobeautify      flash           mesg            noredraw        nosourceany     wraplen=0
                cdpath=":"      hardtabs=0      nomodeline      remap           tabstop=8       wrapmargin=0
                cedit=""        noiclower       msgcat="./"     report=5        taglength=0     wrapscan
                columns=108     noignorecase    noprint=""      noruler         tags="tags"     nowriteany
                nocombined      keytime=6       nonumber        scroll=17       noterse
                nocomment       noleftright     nooctal         nosearchincr    notildeop
                noedcompatible  lines=36        open            nosecure        timeout
                directory="/tmp"
                fileencoding="UTF-8"
                inputencoding="UTF-8"
                paragraphs="IPLPPPQPP LIpplpipbp"
                recdir="/var/tmp/vi.recover"
                sections="NHSHH HUnhsh"
                shell="/bin/zsh"
                shellmeta="~{[*?$`'"\"
                term="screen-256color"
                
                1. 2

                  Of particular note, the lack of expandtab in Nvi and Traditional vi may be more of a showstopper than lack of multibyte glyph rendering for many.

                  1. 1

                    the lack of expandtab in Nvi and Traditional vi may be more of a showstopper than lack of multibyte glyph rendering for many

                    You’re probably right about the numbers: more programmers would care about tabs and spaces. But I’m a weird case. I program as a hobby, but my job is teaching Latin and ancient Greek. I need my multibyte characters. Thanks for these details.

                    1. 2

                      I can’t promise a time-frame, because doing it means doing it right, so I can get the changes up-streamed.

                      I don’t want OpenVi to diverge greatly from OpenBSD’s vi, because the maintenance burden would be too great, with too high a risk of introducing subtle bugs.

                      Edit: I’ve added some individual features, and likely will continue to do so conservatively, but these are all essentially stand-alone and don’t require invasive changes to other parts of the source tree, which multibyte will require.

                      Edit 2: One of these new stand-alone features is the visibletab (or vt) option, which is extremely handy for editing Makefiles, so the usage of tabs is visible and the alignment respects your tabstop value. Feel free to try it out, and compare it to using the standard :set list mode.

                      OpenVi’s :set vt is the equivalent of using :set list and :set listchars=tab:~~ in Vim or NeoVim.

                      1. 2

                        I can’t promise a time-frame, because doing it means doing it right, so I can get the changes up-streamed.

                        I completely understand, and (obviously) I’m one random person who needs UTF-8 constantly.

                        In any case, OpenVi looks very interesting, and I will definitely take it for a spin. Thanks for your work on it.

                2. 2

                  And finally for those interested in UTF-8, cleanly doing UTF-8 support (the “right” way) is planned but is certainly non-trivial … for example, see:

                  https://www.openbsd.org/papers/eurobsdcon2016-utf8.pdf and http://www.usenix.org/events/usenix99/full_papers/hagino/hagino.ps

                  Nvi2 (and Nvi1) are excellent editors, but I wouldn’t want to copy the Nvi2 implementation directly. This has been talked about elsewhere**

                  ** https://misc.openbsd.narkive.com/9NHoQv8L/nvi-and-unicode#post4