Tips on compiling vi from source
The vi editor is probably the most famous editor on UNIX with a long history attached to it.
Since the software itself is really old, there are some modifications that have to be made in order for it to be compiled and run on a modern Linux system.
First start by modifying the Makefile and change the following variables:
INSTALL = install
TERMLIB = ncurses
The Makefile by default specifies TERMLIB as “termlib”, which to my knowledge is old, obsolete and non-existent on a modern Linux distro.
Next modify two macros in config.h to prevent a “terminal too wide” error from vi:
#ifndef VMUNIX
#define TUBELINES 70 --- do not modify this
#define TUBECOLS 160 --- do not modify this
#define TUBESIZE 6000
#else /* VMUNIX */
#define TUBELINES 47 --- modify this
#define TUBECOLS 174 --- modify this
#define TUBESIZE 16000
#endif /* VMUNIX */
The above macro values works on a suckless terminal on the dwm window manager, however if you still get the “terminal too wide” error, run the following command to see the amount you need to set in the macros:
set | grep -E 'COLUMN|LINES'
TUBECOLS corresponds to COLUMNS and TUBELINES corresponds to LINES.
EDIT:
I have also created an “uninstall” target that you can add to your Makefile if you want:
uninstall:
rm $(DESTDIR)$(MANDIR)/man1/edit.1\
$(DESTDIR)$(MANDIR)/man1/vedit.1\
$(DESTDIR)$(MANDIR)/man1/view.1\
$(DESTDIR)$(BINDIR)/edit\
$(DESTDIR)$(BINDIR)/vedit\
$(DESTDIR)$(BINDIR)/vi\
$(DESTDIR)$(BINDIR)/view\
$(DESTDIR)$(MANDIR)/man1/ex.1\
$(DESTDIR)$(MANDIR)/man1/vi.1\
$(DESTDIR)$(BINDIR)/ex\
$(DESTDIR)$(LIBEXECDIR)/exrecover\
$(DESTDIR)$(LIBEXECDIR)/expreserve
rmdir $(LIBEXECDIR)\
$(PRESERVEDIR)