http://www.educ.umu.se/~bjorn/unix/wizard.html
Fun with vi, nvi, and vim
Some time ago, I installed the old version of vi ported as part of the heirloom project, noted as Traditional Vi. I tucked it into ~/code/C/src/old-vi and put a symlink named ‘ovi’ in my $PATH. During initial testing, I quickly concluded that the nvi builds on modern BSD (the systems vi) are considerably more extended then what the traditional vi offers. Things that I noticed most missing, were that ‘~/’ in file names was not expanded to the value of ${HOME}/ like in the shell (nvi / vim expand ~/), and the (crappy) split window support and a proper implementation of . and ^R (nvi makes ^R behave like .). A little playful testing also showed several settings missing (mostly expected), and no :exusage or :viusage commands. (Useful in nvi/nex on occasion, to see just what is available without consulting a reference or vim :help.) Two things I’ve learned tonight, old vi and nvi both support abbreviations, and control+^ is down right handy for switching buffers (vi, nvi, vim; probably every vi clone ever made). I thought abbrivations would have been an Elvis invention that made its way into vim, but I guess it was there since the 1980s, hehe. I also noted that ovi/nvi react differently to showmode (I prefer ovi’s).
Out of curosity, I fed into vi my nvi configuration file, since it appeared to be ignoring my ~/.exrc. Only had to remove the matchtime / ruler settings, and two of my mappings: gg and ZQ. gg being a vim’isms for 1G (go to first line in file) and ZQ being a very logical vim’ism for :q!^M much like vi used ZZ for 😡 .After that, vi accepted it without problem. The errors about the mappings interestingly said, “To dangerous to map that”, but nvi doesn’t give a darn. Fair enough for gg, but I’ve yet to figure the ZQ one yet.
Traditonal Vi
~
~
~
~
~
~
~
:set all
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
noexrc redraw noterse
flash remap timeout
hardtabs=8 report=5 ttytype=screen
noignorecase scroll=11 warn
nolisp sections=NHSHH HUnhsh window=23
nolist shell=/usr/local/bin/zsh wrapscan
magic shiftwidth=8 wrapmargin=0
mesg noshowmatch nowriteany
[Hit return to continue]
FreeBSDs build of nvi, when invoked as vi or nvi:
+=+=+=+=+=+=+=+
noaltwerase noextended matchtime=3 report=5 term="screen"
noautoindent filec="" mesg ruler noterse
autoprint flash nomodeline scroll=11 notildeop
noautowrite nogtagsmode noprint="" nosearchincr timeout
backup="" hardtabs=0 nonumber nosecure nottywerase
nobeautify noiclower nooctal shiftwidth=8 noverbose
cdpath=":" ignorecase open showmatch warn
cedit="" keytime=6 optimize showmode window=23
columns=80 noleftright path="" sidescroll=16 nowindowname
nocomment lines=24 print="" noslowopen wraplen=0
noedcompatible nolisp prompt nosourceany wrapmargin=0
escapetime=6 nolist noreadonly tabstop=8 wrapscan
noerrorbells lock noredraw taglength=0 nowriteany
noexrc magic remap tags="tags"
directory="/tmp/"
msgcat="/usr/share/vi/catalog/"
paragraphs="IPLPPPQPP LIpplpipbp"
recdir="/var/tmp/vi.recover"
sections="NHSHH HUnhsh"
shell="/usr/local/bin/zsh"
shellmeta="~{[*?$`'""
Press any key to continue [: to enter more ex commands]:
And doing :set all in Vi Improved (VIM) is so huge, it requires a pager! Hahaha.
Generally I will use vim whenever it is made available, in fact I usually compile my own binaries for it via shell script. But I have spent enough time using nvi, that dipping into ed, ex, vi / nvi don’t bother me. When I invoke vi, I expect a fairly traditional vi; when I invoke vim, I expect vim with vi compatiblity mode turned off (e.g. as if invoked as vim -U NONE -u NONE -N), or vim to behave ‘as expected’ when my own vimrc file is around.
My ~/.vimrc is over 1000 lines, but if you strip blanks and comments it is closer to 600. The only customizations that I actually depend on however, is mapping ‘;’ to ‘:’. Although certain vi users find that to be ludicrous, I use :ex commands much more frequently then I need to repeat the f, F, t, and T commands in the same direction. So being able to say ; when : is needed, is a massive life safer on my fingers, because it removes the need to hold shift. In fact, unless I want to go to a specific letter in a word, I usually employ :/ and 😕 to search for the word, rather then a linewise [count]f[character] motion, so the loss of a standard ‘;’ is fairly low for me.
I find vim much more comfortable then other vi’s, because I spend an imense amount of time in a text editor. I often [ab]use vims :sp[lit] command to have multiple edit-windows open, or to edit the 2 different parts of the same file without using marks or tags to jump about. The gq operator in vim is also a thing I love, because I can quickly reformat text without having to invoke an external program like fmt(1) all the time. Vi Improved also has better tag based commands. The ability to auto complete :ex commands and file/directory names helps me greatly; nvi’s cedit extension for editing :ex comand history sucks in comparason. The ability to :e . and use vim to peruse the current files in a directory is also nice when dealing with some peoples projects, although :!ls | less would work too, I’m not fond of the hit enter prompt at the end (nvi also ditches the colours in my ls output, while ovi retains them). The ability to use code folding and quickly configure settings based on file type is also quite nifty, since I often use zM to fold everything in large files, take a look and zO things that /look/ like it is what I am looking for. I almost never use ^O to make a single normal mode command from insert mode (vi/nvi don’t seem to support it), but it is nice when combined with other control+ commands in vims insert mode.
I’m also partial to vim’s undo style that repeatidly pressing ‘u’ in normal mode, repeatidly undo’s things while ^R redos what was undone. Traditional vi, nvi, and vim with u in the vi compatiblity options all have semi-incompatible usage paterns. The Vi Improved way uses u as noted above, when set to use a more Vi compatible way, vim uses u to undo and ^R to redo. Because vim has unlimited undo/redos, this means we would press u to undo the last change, then ^R to ‘redo’ the previous commands, and a following u will undo will undo the last redo (undo redo redo undo; rather then undo undo undo redo). Nvi allows using the ‘.’ as a synonym for ^R which is convenient since ‘.’ means repeat last change command. While traditional vi seems to lack multiple levels of undo/redo period and end of quote.
vim style multi undo:
dddddd -- delete the next 3 lines as 3 separate changes (3dj would be a single change)
uuu -- undo last 3 changes (i.e. undeletes those 3 lines)
^R^R^R -- redo last 3 undos (i.e. re-delete those 3 lines)
nvi style multi undo:
dddddd -- delete the next 3 lines as 3 separate changes (3dj would be a single change)
u -- undo last change (undelete last line)
^R^R -- redo last 2 undos (i.e. undelete the previous 2 lines)
vi style undo:
dddddd -- delete the next 3 lines as 3 separate changes (3dj would be a single change)
u -- undo last change (undelete last line)
u -- redo last undo (redelete last line)
(i.e. vi style undo just toggles between undoing the last change and undoing the last undo, and ^R is subverted to allow multiple undos/redos in vim/nvi)
I’ve been using the vim style multi-undo for years, but have been wanting to adjust myself to the nvi style for ages. The only problem is, if I have to undo then do redo’s, I prefer using ‘.’ instead of ^R, haha! It seems to me, that technically nether vim using ^R for redo, nor nvi extending . for redo is purely vi compatible; but I personally feel extending . for the purpose, rather then clobbering ^R is a more logical solution. Although I can’t really think of a reason to use classic vi’s ^R instead of ^L on a modern terminal (read CRT or emualtor based terminal). The nvi style of multi-undo/redo also makes more sense to me, although most software users have been heavily conditioned by most programs to expect ^Z to undo the previous change up until the programs built in limit on undos.
Vim provides extensive mapping, syntax highlighting, build system integrations, and buffer options compared to traditional vi’s, but I don’t actually depend on it. Although most programmers I know, will cut your head clean off if you don’t give them syntax highlighting (lol), I don’t use Syntax highlighting…. I used to like using the astronaut and elflord colour schemes in vim; because I found them good for visually dumping syntax into my head. I.e. you can quickly tell what is what kind of syntactical element. But ever since I had to spend hours hashing out new PHP and SQL in a colourless remote terminal, I started to find the syntax highlighting to be distracting :. The only times I actually use colours in vim anymore, are for directory listings, with other peoples HTML, and in my .vimrc file; when coding, I use no syntax highlighting what so ever.
If you can look at the horse-shit filled tangles of (broken) HTML, (idiotic) SQL, (kindergartener like) PHP, and occasional JS that are so horribly intermixed and mutilated, that some past [SAS] webmasters dared to call it code, and come to reading it without syntax highlighting…. you can live without syntax highlighting anywhere!!!
Quote of the Day
Better a witty fool than a foolish wit.
— Feste the clown, Twelfth Night, Act I, Scene 5, William Shakespeare
Never read Twelfth Night, but the quote caught my eye lol.
Wouldn’t it be wonderfull… if I could actually get work done during the day, and not have to be some damn badgered that it takes hours to do what should be done in minutes? And I was hoping to be able to shave tonight, without losing nearly an hours worth of work :
WTF was I thinking? *SIGH* my mother enjoys driving me fucking nuts with pestering and patronizing me about getting up in the morning / staying up all night. BUT FOR FUCK SAKE!!!! She is the one incrementing my fucking work load by hours at a fucking time!!! I really wish there was a way, to make people see things “as they are”, without either having to break their neck or emotionally-cut them in the process, because I’m not fond of either method lol.
Joy, the slave gets called for more interuptions…. (Bitch)
Sometimes I wonder…. if there is actually a human being left alive, that knows their ass from a hole in the ground… when it comes to creating robust software.
Dogs take everything!
This morning, Ma woke me up laughing…. Willow had managed to steal my entire quilt, and rapped herself up in it: leaving me with just the top sheet lol. So I patted the dog on her head, and asked if I could have some of the covers <_<.
Willow looked at me, like I had corn cobs coming out of my ears! SO I stole the cover back, and went back to sleep chuckling >_>.
Mrs S. was right, if you want the best spot in the house, ya gotta move the dog!
[SAS] — All the way live baby, all the way live!!!
Yippee-Kay-Aye! I’ve just finished the majority of remaining server setup that needs doing. So far, it feels like [SAS] is gonna have some kick ass servers going hehe. I spent most of my day helping Wiz with the odds and end; looks like we will have a fairly seamless transition to the new server machines tomorrow. The only downside is we’ll have to update our “favorites” in RvS’s server browser, and Servers/SWAT4 on XFire also. Beyond that though, looks like we are locked, cocked, and ready to rock’t and roll.
Thanks to Wiz’s curiosity and my backups, we don’t even have to screw around with our communications service! Although, I think we learned a bit more about the software then we originally bargained for, but hey, job done, task done, mission complete, was a piece of cake. Hmm, technically we might even be able to have double our usual server capacity tomorrow for a lit’ bit before change over takes place…. Hmm, *evil grin*.
At around 8:00 AM PST on Friday, January 30, Ma.gnolia experienced catastrophic failure to it’s primary and backup systems, and is offline while we attempt to repair and recover service.
DANG. It’s a good thing, I remember most of my bookmarks via URL and Google, b/c I’ll be waiting until they go back online to be able to access my bookmarks lool.
Another day in a slow hell done, another empty night nearly gone by, and a busy Friday is looming on the horizon.
So far, I’ve been spending most of my time reading the days away. Almost finished reading Programming Perl which is a nice book, been a long time since I’ve been able to read anything that length (I prefer Fiction). Higher-Order Perl has also been on the hit list recently, but haven’t had to much time to spend on it the past half-weekish; so far, I think HOP should be required reading for every programmer, perl or not lol. (If the concepts in it are new to you, please don’t sit next to me!) I’ve also been inhaling one of my favorite classics, The Art of Unix Programming; don’t think I’ve ever finished it, but hey… about it’s time, and I’ve got plenty of time to pass…
I’ve also interspersed the days routines with working on one of my larger (Perl) projects whenever I’ve got the mental resources free, and otherwise dealing with [SAS] Business whenever possible; tomorrow + the weekend is gonna be a long stretch. One way or the other… I’m going to get some drill time on SWAT 4 back in my schedule, if I’ve got to start playing at 0500R lol. Ops have been going quite well, on both sides of that coin. Mostly, it has just been a problem of getting stuff done around my family, and ever mounting levels of exhaustion… Earlier today, I remembered something I used to say in response to everyones frequent “break times”. Namely, that I’m not allowed to get tired, because if I did, I would be poked and prodded into continuing on; for all intents and purposes, that is just what my family is doing to me now >_<. I really need a _long_ vacation, one very far away from this place and virtually everything in it. Really, my life would be a lot less painful, if I just learned to stop caring; but then I wouldn't be myself, would I? Despite periodically being pushed to drop my principles (particularly whenever they interfere with my mothers demands), I've generally refused to compromise -- or as my mind repeats on occasion, they may kill me or crack the walls of my defenses, but they will never break me… Only GOD can do that. Sometimes, I feel like the only person around here that actually gives a damn… Oy. I remember many yars ago, I tried my part in establishing peace; only to be treated like a fool, guess my family liked it the way things were spiralling. Eventually, I gave up and left everyone to their own mutally-destructive ways of dealing with one another, and dived into the cover of working myself into a stupor. The past few years, have actually been the most peaceful in a very long time… Maybe since ’94 or so. Heh, I remember how as a child, I used to count my families larger squabbles in terms of “Family World Wars”, since within the scope of our family, it was on the same scale of fighting; I lost count around 7 or 9. The difference being though, while most of the in-fighting has settled down (Thank GOD) in recent years, it seems the side effect is I’m more or less a primary target rather then a chip on the table… Fuckers never would respect my neutrality policy, so why would I be surprised? If the character of Ernest P. Worrell should have “He never knew when to quit” written on his tomb stone, they should write on mine… “He never knew when to just keel over and die”.
The worse these days get, the more I think about what a /good/ day could have been like. The more it hurts, looking at what I’m chained to (in some ways, chained, bolted, and gamma-welded into this hellhole) to this rats nest; it is all the more that I long for change, and for freedom. What can I say? I hate my life…. I have enough trouble getting a decent nights sleep here around here, like I really need all this other crap tacked on at home? FFS, I don’t think I’ve really slept decently since the early 90s., not a good thing, when one considers that I was only born in ’88 lol.
Somehow, I don’t think the word surrender was ever programmed into my volcabulary.