Indeed. Nvi, which was recommended elsewhere in the thread, supports UTF-8 and is my preferred vi clone. (Actually, OpenBSD vi is an old version of nvi without UTF-8 support.)
It isn't for everyone. I have never come across a real need for more than standard ASCII in any of my work. It absolutely isn't needed for managing unix config files, which is the primary use case for "lightweight" editors like this.
Congratulations on English being the one and only language you use to make quick notes, then. I personally mix in words from my native language wherever I need an extra bit of semantic precision, and I'd rather not have to switch between editors to do so.
For multilinguals (which is over half of the world's population), throwing in terms from another language or entirely switching to a different language mid-sentence during a conversation is entirely normal. I can't imagine it being that rare in personal notes.
Presumably, any number that prefer a terminal based workflow, or have the Vi key scheme burned into muscle memory. Or those that prefer an ultra-minimalist text editor for writing.
Just a decade ago, it was almost a meme that the Emacs and Vi factions fought over which editor is better. I imagine that those that truly bought into the Vi ecosystem/fandom use it in preference to other available options.
You're speaking to a veteran of said editor wars (vi won, naturally) and I still think the number of folks you describe is small these days. I imagine most have switched to a more GUI-friendly editor.
Is it not a feature given how many security issues come out of parsing? There is virtue in the thing you’ll edit files with as root being as simple as you can make it.
Yes, and also vim and other vi clones.
But what is the point of having a secure and integrated OS if you have to pull software from ports (which are not so thoroughly audited and tested as the main OS)?
One point of using BSD is (so the BSD people say) to have an operating system where everything comes from the same team - kernel and userland, unlike Linux where kernel and userland comes from dozens if not hundreds of different origins. But if you start to use arbitrary ports in BSD your OS is not much better than Linux in that regard
Historically, this is why basic vi (of whatever flavor) was so popular. I could hop on any Unix and it was there OOB. I dealt with some mixed set of Solaris, BSD, HP-UX, Irix, Tru64, AIX, and Linux for so long.
For a host I did primary development on, I’d install vim (visual mode and then syntax highlighting was so nice).
But we managed config centrally with idempotent scripts that handled the differences (like no getent on HP-UX). We did have to install ksh88 or a clone everywhere to get a stable consistent shell. GNU was flaky on so many platforms then.
Vi was always there for those WTF scenarios, less as a primary programming editor. And it is so nice on slow connections, where repainting the whole screen for every keystroke sucked.
It really annoyed me when Linuxes dropped the basic vi everywhere in favor of nano. I’d be fine with nano as a default for accessibility, but at least have some vi in my path.
Our standard images include it, but I always forget when I’m testing/debugging locally with Vagrant or a Docker image.
Vi is always a little weird. I don’t think any 2 people use it the same. Everyone has their own go-to set of commands. Pairing with grey beards influenced me so much.
I actually started with emacs in college, but real life with 1,000s of servers forced the change. I don’t have the muscle memory for it anymore and have no desire to go back.
Nowadays my local neovim config is almost VSCode. But I still like VSCode-ish in vi more than vi-ish in VSCode. I tried, but inevitably do something that VSCode’s vim plug-in doesn’t support.
I do use go more and more for complex stuff, but often am forced back to shell due to old kernels still out there which hurts my soul.
> It really annoyed me when Linuxes dropped the basic vi everywhere in favor of nano. I’d be fine with nano as a default for accessibility, but at least have some vi in my path.
Don’t nearly all distros still have something (usually nvi or vim) in /usr/bin/vi out of the box?
The behavior of the traditional vi is much different than vim and other clones. Nvi was a actually a re-implementation of the traditional vi for 4BSD (to be clean of AT&T code) and thus was originally intended to be bug-for-bug compatible, but breaking away where the original vi behavior was nonsensical or terrible.
For vim, `set compatible` or `set cp` is close, but still not traditional vi by any means.
Despite the very similar names, all of these editors have a variety of different features, and are structured very differently.
Nvi has a concept of a front-end and a back-end (which uses the BDB database). OpenVi uses the OpenBSD version of Berkeley DB which derives from 1.85. Nvi (1.8x) provides a minimal version of code also derived from that release intended from use with Nvi, and (IIRC) also provides support for using Db3/4/5. Similar situation for Nvi2.
Nvi 1.8 has been structured where a third library layer has been added, which doesn't exist in OpenBSD's vi or OpenVi. There is scripting support (Tcl, Perl, etc.) and GUI code in the other various forks ... all of these support various different options as well.
I should probably make a matrix of these, but you can get an idea by looking at the settable options implemented in each of the variants (as they historically include a comment to document from where the option originated):
For that level of UTF-8 editing, a non-mulitbyte version of the editor suffices. In fact, you can insert and modify multibyte signatures and names using the map facility, however the glyphs are not rendered on screen but are shown at the byte-level.
Improvements are in order, and should be made, but the mere inability to visually render multibyte characters is not always a showstopper.
Or it could be just as simple as me jotting down some notes in my native language, which includes such exotic characters as ę and ą. You know, so I don't have to go back to using a code page like back in good old DOS days, that I'm actually too young to have lived through.
It isn't really an "old" version of Nvi by any means - the development went in a different direction. OpenBSD's vi has been developed mostly independently since being imported back in 1997.
In the 25 years since the "fork", OpenBSD vi has diverged significantly from Nvi1 (as Nvi2 has diverged from Nvi1 as well).
It has grown much smaller and more compact - one might argue more focused.
Much of the code has been simplified and many features removed, rather than added. Still, it has adopted features and taken some fixes back from Nvi1/Nvi2 versions and other variants, such as adopting support for expandtab from NetBSD's variant.
Changes to the (OpenVi bundled) OpenBSD regular expression engine are not included in the legacy ChangeLog, but you can see that development in the CVS tree or via GitHub as well (https://github.com/openbsd/src/commits/master/lib/libc/regex).
If you want to go ultimately minimalist http://ex-vi.sourceforge.net/ builds and runs on most modern systems just fine.
Having learned vi across eight-ish different unices at once my muscle memory is very minimalist so I tend to use ex-vi preferentially, simply because everything else adds features I don't use that I can accidentally activate with a typo and break myself out of flow figuring out wtf just happened.
I can absolutely imagine that for somebody who tends to use OpenBSD on their own machines, being able to have the exact same editor elsewhere could be really quite handy for much the same reasons.
Using Carsten Kunze's actively maintained continuation of Gunnar Ritter's (outstanding) traditional ex/vi project is highly recommended. See https://github.com/n-t-roff/heirloom-ex-vi/.
The parent project on SourceForge hasn't had any activity for 15 years, nor a release in 17+ years, and contains various known bugs, all of which are fixed in Carsten Kunze's project.
That sounds like a better idea for everybody who isn't me.
Naturally I've accumulated a few local patches over the years so I'll have to figure out which of them are obsoleted by the improvements in that version and which of them I want to port first ;)
(thanks very much for sharing that this exists though, I shall be digging in when I have available tuits)
I also ported it to use malloc instead of treating the heap as a single giant array, though a quick look suggests they did it rather more competently (though admittedly given my C code that's really not a high bar to clear).
I suspect that once I untangle my somewhat hacky version of that the remainder of my patches will apply just fine but there'll still be at least a bit of mental effort involved.
Probably nothing that interesting - the malloc stuff was the big change and n-t-roff already did a much better job of it than I did.
But if there's anything in the remaining stack once I've backed it out that seems useful I'll be sure to PR it - even if it doesn't make it in to mainline it seems as good a way to memorialise the patch for other people's use as anything else.
(the repo is currently private because gritter had politely requested nobody make it work on windows and one of my patches worked around a cygwin bug - given the advent of WSL I doubt anybody would want that one anyway so I expect to let it be lost to time along with the half-arsed malloc code)
I've been using busybox vi as my root editor but it doesn't have secure mode which disables shell access within vi. It looks like OpenVi and nvi2 have them. Are they preferable to busybox vi if I want better security as a root editor?
If you’re that paranoid, isn’t it better to run the editor on some other machine? E.g vim with scp support? Then there’s no editor to infect/replace/screw with on the Important Server.
Secure mode doesn't really make anything more secure if you're the one using it. It just lets you add it to the list of allowed commands in the sudoers file without giving someone a root shell. We used to do that all the time at one job that didn't let you log in as root and wanted you to do everything through sudo. You'd just sudo vi /some/random/file and then :! and have a root shell.
OpenVi uses only secure functions (snprintf, strlcpy, etc.) as a matter of policy.
This may lead to a more secure editor for untrusted files, but it depends on how careful the other editors are. (I haven't examined them at that level.)
It's nvi plus some OpenBSD patches. Nvi it self has a series of different patches. The question remains valid. Why would you specifically want the nvi from OpenBSD, when you already have nvi?
The assumption has to be that OpenBSD added something to their version of nvi, which would "justify" porting it back to non-OpenBSD systems. What those feature are I don't know. It might just be a fun exercise adding the portability back.
I have some comments here that address this, but, there are in fact many significant differences.
The OpenBSD version forked at Nvi 1.79 around 1996-1997 and has been developed in the OpenBSD base system for 25 years now, and has diverged greatly from Nvi. Nvi2 has also diverged significantly from both "upstream" Nvi and OpenBSD vi.
The OpenBSD release has significantly trimmed features and maintains a different structure than the others as the philosophy completely different. There is no Perl / Tcl / pluggable scripting engine support or alternate graphical user interfaces or similar.
There are significant differences in the lower level code for signal handling, options, etc.
While the core functionality of these editors are all largely the same, and they all share common heritage from Bostic's Nvi, there are trivial and non-trivial differences between all of these editors that are almost too numerous to summarize.
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 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 heritage as well but also, quite far removed from the original code, is actively maintained at https://github.com/lichray/nvi2 and also includes multibyte support.
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 280K, 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't provide an really fair comparison yet, but I will, and I'll summarize the data in an FAQ section of the README)
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:
280K bin/vi
(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.
But, these are all different editors at this point. A lot happens in 25 years.
I have updated the documentation/README to provide background and rationale, and elaborated a bit on other comments.
OpenBSD's vi (and OpenVi) differ distinctly from both Nvi (https://repo.or.cz/nvi.git) and Nvi2 (https://github.com/lichray/nvi2) in terms of features and support, having diverged 25 years previously, where the OpenBSD/OpenVi branch has embraced minimalism and simplicity.
For a quick and non-scientific comparison, C source lines of code (as counted by tokei) for the various distributions of the Nvi-derived editors:
Nvi - 62,315 SLOC
Nvi2 - 32,408 SLOC
OpenVi - 40,065 SLOC
And looking ONLY at the core editor functionality and bundled regular expression engines:
I will confirm that Vile is an excellent editor. I don't know if I'd consider it a vi-clone, because the vi-ness is kind of skin-deep, but it's performant and works well.
(In school, early 90's, there was a large vile following on VMS, which is where I mostly used it. I don't recall why it was preferred to Vim on VMS, however. Perhaps we didn't have Vim easily available or installed. But I digress.)