Entering control key chords into nvi

Updated on .

A major idiosyncrasy of The nvi text editor is how key chords are specified in the mappings and macros. nvi doesn’t support aliases like vim’s <C-R> for representing these keys, so they must be inserted as raw control characters (normally not printable) in the file. This isn’t ideal for diffs in version control, but it “makes sense” from an implementation perspective – mnemonics for control characters would need to be translated by nvi’s command interpreter.

Type control-v to have nvi treat the next key as literal input, and then type the letter while holding down control.

Spaces are even trickier, requiring a literal control-v (type control-v twice into the editor) and then control-v followed by the space bar. It took me a while to figure this out, since it’s not clearly described in the manual.