The original source code of the vi text editor, taken from System V
github.com
github.com
set autoindent
set ruler
set showmode
My biggest struggle has been finding good resources to learn the "proper" way to use it as pretty much any search will land you with vim-isms and no one "serious" really uses vi(1). Matt Widmann did write a few good pieces though [1,2].[1]: https://mattwidmann.net/notes/modern-nvi-mappings
[2]: https://mattwidmann.net/notes/entering-control-key-chords-in...
The only seemingly unsurmountable hurdle I can think of is the inability (as far as I can tell) to bind control key chords to movement in insert mode. But maybe I am simply "using it wrong" and need to adapt my thinking to suit the tool?
It gets very close, but there are some extra features (e.g. multi-window, multi-undo) and subtle incompatibilities in some cases.[1] Either way, I suppose its feature set is much closer to that of traditional vi.
> My biggest struggle has been finding good resources to learn the "proper" way to use it
I would recommend reading through the manpage, I've learned a lot doing that. Some tips:
* Most line-oriented operations in vim that are missing from vi can be done using filter commands. e.g. you can emulate vim gww as !!fmt.
* vi has no cib, dib, etc. But it has %, which is usually good enough.
* Visual mode is vim-only, but marks come from vi (which, in general, can be used for the same purpose).
* If you're using nvi, you have multi-level undo too (try u.....). In traditional vi, the best you can get is "1 "2 ... for deleted text (and U for restoring saved lines).
> The only seemingly unsurmountable hurdle I can think of is the inability (as far as I can tell) to bind control key chords to movement in insert mode.
Yeah, vi is fundamentally a modal editor, if you want key chords you're probably better off using emacs. (Or *vim, I guess.)
That said, you can define abbreviations, which work in input mode. e.g. I use an adapted version of the HTML abbreviation file from https://thomer.com/vi/vi.html#macros. (Most links are dead, unfortunately. But the HTML abbreviations work.)
[1]: At least in my nvi version (nvi2):
iabcd^[:s/b/^V^M^M
places the cursor on the line with a. Heirloom vi and vim both place it on the line with cd. Probably an nvi bug.
If I'm not mistaken, undo tree in 2023 is still almost an exclusive feature of vim, even the most popular IDE - VScode doesn't have a way to recover state before undo + typing, aka GURQ https://github.com/zaboople/klonk/blob/master/TheGURQ.md
[1] https://www.gnu.org/software/emacs/manual/html_node/emacs/Un...
[2] Here is a screenshot from 11 years ago: https://www.emacswiki.org/emacs/UndoTree#h5o-5
Why stop at vi? Go all the way and re-orient your entire lifestyle around Unix text processing: vi, awk, sed, troff, and sh.
Is that what you do in vim? I use vim, but haven't come across that before.
It does seem consistent with the basic concept not to have or to need insert mode bindings (of any kind, except return to normal mode, since all you're doing is inserting the characters corresponding to your key presses) to me, so maybe '"using it wrong"'.
> But maybe I am simply "using it wrong" and need to adapt my thinking to suit the tool?
Maybe a better way to think of it as all of these struggles are WHY vim exists? Mission accomplished, go back to vim :-)
I started using fred (like ed on steroids) in university(1), graduated to vi during workterms, eventually used stevie(2) and elvis(3) for a few years before landing on vim in the 90s.
vim has moved so far past all of those that it's like driving a model T to understand where your tesla came from.
(1) https://www.texteditors.org/cgi-bin/wiki.pl?FRED
If you want something closer to the original Vi experience, the lesser known “nvi” (not to be confused with “nvim”) follows the original UNIX behavior much more closely.
It seems to be the default in BSD and some Unix distributions. Last I checked 10+ years ago Debian shipped its base system with nvi. Many many years ago (20+) I actually used nvi in a programming competition because the only alternative was a horribly buggy IDE thing (the host organizers was trying to switch from windows to Linux as the default env but a bunch of support wasn’t quite there yet). nvi is actually quite usable as long as you’re not too deep in the Vim-isms
Later I discovered that you can use visual mode with a small number of lines (:set lines), which was much more pleasant. Also I got a 14k4 modem which solved most other problems.
I love vim, but vi is too spartan for me.
[count] command [argument ESC]
I have never seen direct confirmation that vi commands were modelled on TECO, but they seem too similar for it be entirely coincidence.Start with the original tutorial, An Introduction to Display Editing with Vi.
Learning to edit primarily via ex mode in vi and vim (commands that start with a ':') is the true vi super power in my opinion.
edit: typos
It took some study of man pages and trial and error to achieve what I needed, but I was able to get it done.
I know there are Linux distributions now that don't even include ed by default, even though it's in POSIX and occasionally used in scripts.
best shell available was ksh, and the only really usable mode was vi mode.
in addition the only worthwhile editor available on this system and customers was vi. (IIRC emacs was obtainable but not installable on customers machines, and heck of a lot slower than vi)
:2s/wa/i/gThis is a significantly evolved version. The Berkeley copyrights are 1981, so it's probably from 4BSD.
It's 14,801 lines of C and 640 lines of C Headers, with 4,722 and 589 lines of comments respectively. There's also 285 lines of assembly.
It's been a long day.