Text Editors


When writing code and lab reports, there are a variety of options to choose from when it comes to editing files. The most commonly used editor (at least around these parts) is emacs, though vi is popular as well. Each of these features a lot of keyboard shortcuts that will (eventually) allow you to work without lifting your fingers from the keyboard. At least not too much.


Emacs


At the Unix terminal, simply type
/home/username% emacs [filename] &
and a new text editor window will open up. If [filename] already exists, that file will be opened, and if [filename] does not exist, then a new file will be created with that name. The ampersand at the end simply indicates that you want to open a new process for emacs, which allows you to continue using the terminal which was used to open emacs.


There are a couple of guides that help give a sense of what you can do in emacs. The first guide (ps or pdf), by Nicholas Hakobian, details the basic layout of emacs, and tells where to find simple commands in the menu. The second guide (ps or pdf), by Professor Heiles, would perhaps best be described as a list rather than a guide. It gives the keyboard shortcut for most any task that you might want to perform in emacs.


Vi


To use vi (or vim, which is vi improved), type
/home/username% vim [filename]
at the Unix terminal. Note that an ampersand is not used here, as vi takes over the terminal in which it is opened. Moreover, within vi, the not-using-the-mouse philosophy is taken a step further. Within emacs, there is a menu, and one can use the mouse to perform tasks, though it is often quicker not to. When using vi, you might as well not have a mouse, as there is no menu and you can only move around in a file using keystrokes, not mouse clicks. It is also necessary to switch back and forth from editing mode to navigation mode. This great reference sheet has basically all the commands you would need to know.


Considering the differences between emacs and vi, the learning curve is a bit steeper for vi, especially for users new to a Unix environment. Some users though find the infile navigation in vi to be a bit easier to manage, at least with regard to having to stretch to strike harder to reach keys. For an interesting diversion, check out the page on Wikipedia devoted to the editor war between vi and emacs. As both editors are great, the best thing to do is probably to pick one and learn it well.