vi: Terminal too wide

Workaround for vi “Terminal too wide” problem

Use the Unix command line and sooner or later, you will be editing text files. One of the best ways of doing that is with the vi editor. It is available as standard on almost every unix/linux system. While other editors are available (ed, emacs, vim, etc), vi is quick and convenient. It offers a good balance between usability and ubiquity.

This article offers a workaround for the annoying “Terminal too wide” problem encountered by vi users on Solaris.

Vi was originally written for screens (terminals) which were 80 characters wide. In a modern windowing environment, the terminal has been replaced by virtual terminal apps – xterm, lterm, Terminal and many others. The width of a virtual terminal depends on how much big you make the window. On a large screen it could easily be 200 characters or more. Continue reading

Simple Locking Wrapper for VI

This post presents a quick way to add file locking to the vi editor.

The vi editor is found on pretty much every unix system, which means it is often used by system administrators to update configuration files. Unfortunately vi does not lock the file being edited. This can lead to two or more people inadvertently editing the same file at the same time. Edits can become duplicated, confused or lost entirely, perhaps leaving the file in a non-working state.

Editing Critical Files

It is bad enough in the case of small files such as yum.conf or ntp.conf. More serious are files like /etc/fstab, where a simple syntax error could lead to an unbootable system. Worst of all are network-wide resources like DNS zone files. A mistake here could mess up more than one machine. Continue reading