Survivalist vi

A few days ago I wrote about computational survivalists, people who prepare to be able to work on computers with only software that is available everywhere. Of course nothing is available everywhere, and so each person interprets “everywhere” to mean computers they anticipate using.

If you need to edit a text file on a Windows computer, you can count on Notepad being there. And if you know how to use Windows, you know how to use Notepad. You may not know advanced features (does Notepad even have advanced features?) but you can get around.

On a Unix-like computer, you can count on vi being there. It was written about four decades ago and ships with every Unix-like system. This post will explain the bare minimum to use vi in a pinch.

Navigating

Arrow keys should work as expected. If for whatever reason your keyboard has no arrow keys or the keys don’t work, you can use the four home row keys h, j, k, and l as arrow keys. Use trial and error until you figure out which way each one moves.

vi has two modes, command mode and insert mode, and it opens in command mode by default. Typing an h, for example, does not insert an h into your text but instead moves the cursor to the left.

Editing

To edit a file, you can enter insert mode by typing i. Now the characters you type will be inserted into your file. What if you want to delete a character? You can delete too, but it’s still called “insert” mode. The arrow keys still navigate, but typing an h, for example, will insert an h into your file. To go back to command mode to navigate more, type the Escape key.

Exiting

If you’re not already in command mode, type ESC to enter command mode.

If you haven’t made any changes, you can type :q and Enter from command mode to exit. If you have made changes, you can use :wq to save the file and exit, and :q! to exit without saving.

Alternatives to Escape

If your keyboard doesn’t have an escape key, as on some Macs, you can use Control-[ as an escape key. (There’s a story behind why this works.)

Similar posts

 

7 thoughts on “Survivalist vi

  1. > does Notepad even have advanced features?

    I haven’t used Windows in a while, but one of the features I liked about Notepad was that if a file had “.LOG” in the first line and that would instruct Notepad to automatically add a timestamp at the end of the file every time you opened it.

  2. If your vi is vim, then arrow keys probably work anywhere. With more traditional versions of vi, the arrow keys may not work at all, or may only work in normal mode, not insert mode (in insert mode, they may insert annoying escape codes).

    If your vi is vim, then you can probably delete things even in insert mode, but in more traditional versions, deletion in insert mode may be impossible, or may be limited to backspacing over things you typed since you most recently entered insert mode. The ‘x’ and ‘X’ keys in normal mode act like you probably expect Delete and Backspace to act.

    If your vi is vim *and* you’re lucky, you may be able to select things with the mouse. Otherwise, move to one end of the text you care about, enter ‘v’ to get into “visual selection mode”, move to the other end, and then enter a command, e.g. ‘d’ to delete the whole thing.

    Many, many other cool things are possible, but they don’t fit the survivalism theme.

  3. David J. Littleboy

    Ah. vi. I worked for AT&T’s Tokyo Unix office back in the day, and could never understand how anyone could stand vi. While I don’t self-identify as a computer survivalist, I could easily be mistaken for one. I use Notepad almost every day, since it handles Unicode (UTF-8) correctly (for mixed Japanese/English text files). I keep thinking I should use something more socially respectable, but every time I try to find something, the creeping featurism problem raises it’s ugly head. Anything more than Notepad has too many bells and whistles, and many of them either don’t handle Unicode or don’t consider it important.

    Also, I “wrote” my own “word processor”, since it’s impossible to write Emacs-like macros in MS Word, but that was just adding search, move, select, replace operations to an early version of the WordPad code. It’s close to being a survivalist-level program, but I used it every day for work (translation) for 20 years.

  4. When I worked on my first book, the French version of The Bayesian Choice, connecting to the mainframe at the Paris University was not yet possible via a modem and I could only use a Minitel home screen and vi. Definitely a survivalist mode!

Comments are closed.