8 ms·
The original source code of the vi text editor, taken from System V
- fargle 3y agoThis is what it looked like about 7-8 years earlier: https://github.com/dspinellis/unix-history-repo/blob/BSD-1/ex-1.1/ex.c https://github.com/dspinellis/unix-history-repo/blob/BSD-1/e...
- mzs 3y agothe guts of visual mode: https://github.com/dspinellis/unix-history-repo/blob/BSD-1/ex-1.1/ex_vmain.c https://github.com/dspinellis/unix-history-repo/blob/BSD-1/e...
- ggm 3y agoI think Joy coded on BSD. So.. this is surely a backplate, no?
- ninjin 3y agoI have experimented a bit with using vi(1) as my main editor to better understand where vim(1) came from. Overall, it is a very functional editor with my rather minimal `.exrc`: 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 https://mattwidmann.net/notes/modern-nvi-mappings [2]: https://mattwidmann.net/notes/entering-control-key-chords-into-nvi 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?
- nuxi 3y agoThis is not a vi tutorial per se, but IMO it's a pretty good overview of the vi philosophy: https://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118 https://stackoverflow.com/questions/1218390/what-is-your-mos...
- OJFord 3y ago> bind control key chords to movement in insert mode. But maybe I am simply "using it wrong" 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"'.
- gpvos 3y agoIn vi (as opposed to vim), you can't just move around in insert mode. An insert/append/change action is limited to one continuous string; the undo mechanism also cannot handle anything more than that. It was pretty mindblowing to me when I discovered vim could do that, it's just way outside the concepts that I grew up with in vi and it still confuses me a bit.
- archargelod 3y agoI started using PC in WinXP era, so vim's multi-undo wasn't very surprising to me. But when I first learned about undo tree - it blew my mind in pretty much the same way. 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 https://github.com/zaboople/klonk/blob/master/TheGURQ.md
- gpvos 3y agoOh, multilevel undo was something that was not hard to fathom and that I yearned for for years. It was the concept of a composite action (edit, move to somewhere else, edit something) while not leaving insert mode that just didn't fit into my idea of what vi was. Would a single undo step undo only one part of that or all of it?
- donatj 3y agoI misread “System V” as “Saturn V” and was sitting here thinking “there’s no way that timeline lines up”. Saturn V rockets stopped being used in 1973, vi was released in 1976. Not as far off as I would have thought.
- deleted 3y ago[deleted]
- Xophmeister 3y agoYou're not the only one! Not until I saw your comment did I re-read to check...which helped answer my question "Why would the Saturn V need vi?" It's been a long day.
- masukomi 3y agoI was curious how big it was. 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.
- ajross 3y agoUh... the "original source code" for ex visual mode was distributed in the original BSD drop in 1978. The AT&T tree didn't get it for a few years at least. This is a significantly evolved version. The Berkeley copyrights are 1981, so it's probably from 4BSD.
- hovav 3y agoIndeed, the History of Documented Unix Facilities [https://github.com/dspinellis/unix-history-man https://github.com/dspinellis/unix-history-man] says a vi(1) man page first appeared in 2BSD, and vi is implemented (as part of ex, with a 1979 copyright) in 2BSD src/ex, with the main routines at src/ex/ex_vmain.c: https://github.com/dspinellis/unix-history-repo/blob/BSD-2-Snapshot-Development/src/ex/ex_vmain.c https://github.com/dspinellis/unix-history-repo/blob/BSD-2-S...
- devit 3y agoThis code implements the most important feature of the editor in question: https://github.com/Cube9999/vi/blob/master/vax/ex_cmds.c#L454 https://github.com/Cube9999/vi/blob/master/vax/ex_cmds.c#L45...
- keithalewis 3y agoDidn't Bill Joy lose the original source he wrote at Berkeley?
- getoffmyyawn 3y agoI think I learned the most about using vi when I worked with an old timer who still used ed. I thought she was crazy at first but watching her edit source code was like watching a wizard cast spells. 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
- bluGill 3y agoI had to learn ed years ago to configure a device that only had a serial port (it didn't run unix or termcap, but they ported ed for configuration purposes). Every once in a while my machine gets bogged down enough that I can pull up ed and make changes faster than vi (vim?) can load.
- SoftTalker 3y agoI had to use ed once in a very minimal rescue environment. I had never used it before, and I also only know vi in a very basic way (emacs is my daily driver). It took some study of man pages and trial and error to achieve what I needed, but I was able to get it done.
- kps 3y agoI used ed for a few months long ago, working with a mainframe Unix-emulation environment that didn't have character I/O working yet, only line-by-line from the host OS. It taught me how to use regular expressions effectively, since they were the only way to make changes within a line. I think I still do a greater fraction of editing with RE operations than most people. 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.
- lloeki 3y agolearned vi when I had to develop on a IBM RS6000 with AIX 3 (or 4, but we had to support AIX 3 as well) around 2008. 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)
- drewg123 3y agoLooking in the source, there appear to be implementations of bcopy (in Vax assembly!!) and printf. Didn't SysV have a libc at this point?