Notes on the nvi text editor
Aside from Vim, I sometimes use nvi as an even lighter-weight text
editor. Don’t underestimate it though, it comes with lots of functionality
built-in.
nvi uses a file called .nexrc in your home folder for configuration.
Here’s an example that I tend to use. Download the file and save it as .nexrc
in your home folder:
=> nexrc.txt
Contents:
1" automatic indentation
2set autoindent
3
4" enable file name completion on <TAB>
5set filec=\
6
7" command editor / history opens on :<TAB>
8set cedit=\
9
10" incremental search
11set searchincr
12
13" press \dd in command mode to insert current date
14map \dd :r !date +"\%Y-\%m-\%d \%a"
15
16" press \dt in command mode to insert current date and time
17map \dt :r !date +"\%Y-\%m-\%d \%a, \%H:\%M"
18
19" press \dT in command mode to insert day of week, full date, time and offset
20map \dT :r !date +"\%a, \%d \%b \%Y \%H:\%M:\%S \%z"