So..didn't take much HTML writing before I started thinking, "huh. Wonder if I could use those function keys in vi". I wondered out loud to a much more Unix experienced friend of mine in 2001 or 2002, and he said, "Why don't you use a .exrc file to set up macros?" "uh..what?"
He sent me a sample. And I ran with it. Unfortunately, this file requires lots of embedded binary characters, like ESC and Carrage Returns (not Unix NewLines), so I'm not going to present the text version here, but rather just a binary you can download and look at:
========================================================Just put that in your home directory, and suddenly, your vi will start using the F keys across the top of your keyboard for various functions, and a few CTRL key sequences, too.
.exrc for download.
My version here has some entries for quirks that the Windows program, PuTTY has.
Entering a control character can be done by hitting CTRL-V, followed by the literal control character you want embedded at that point. For example, a CR (CTRL-M) without a NL would be CTRL-V CTRL-M. An ESC would be CTRL-V ESC
map basically defines a macro -- expand the string given to a set of key sequences. map without the ! at the end means "do this in command mode", map! means "do this in insert mode".
Note that "CTRL-W" in command mode is mapped to a fairly complicated operation -- wrap the entire text in a very basic HTML header and footer.
This was developed on OpenBSD's nvi. May or may not work with other vi-like editors. And you may prefer to use a more sophisticated 'vi' like editor than to try to use the .exrc to fake it. Me, I like to keep my systems as stripped down as possible.
Unfortunately in my environment, F11 and F12 don't work terribly well at all. They produce the same code sequence as F1 and F2.
Be aware that putting a .exrc file in place means this takes effect for ALL
files you edit. My .exrc has proven to be pretty "safe" -- don't recall any
times I've had to deactivate it. But your usage may differ! And if you
screw up your .exrc file, it may make fixing it difficult. (rename it, edit).
Holland Consulting home
Contact Holland Consulting
since June 20, 2021
Copyright 2020, Nick Holland, Holland Consulting.