AMITIAE - Friday 5 October 2012
Command Line Work: New Users and Terminal (12) -- Installed Text Editors - emacs, nano, pico, vi and vim |
![]() |
|
By Graham K. Rogers
There are over 30 text editors for Unix and a few of these are included in the Unix installation on OS X. Unlike the word processors we are now used to, some of these, like emacs, evolved from teletype editors as would be expected considering the Bell Labs genesis of Unix. They are a little more complex until the user is familiar with the commands. The intention here is to be informative rather than instructive: users should make their own discoveries and form preferences. However, as well as indicating the way in to each utility, I will provide the way out.
emacsThere is a manual entry for emacs which may be accessed via the usual command, man emacs which reveals, among a host of commands, that Emacs was written by Richard Stallman and the Free Software Foundation. It has been under development since first produced in the late 1970s.The editor is started by typing emacs at the command line, which brings up a brief information page. The text here refers to C-l to begin editing. This type of instruction is used throughout and refers to the Control key + the letter L.
![]()
Quitting emacs can be done in one of two ways: by using Control + Z which stops the process; or by use of Control X then Control C (Control X plus Control H brings up a list of key translations).
Nano and PicoOf all the Unix text editors, I prefer Pico because of its relationship to the email program Pine, itself now developed into Alpine. This is still available on the server I sometimes access at my university. Pico is one of the text editors installed on the Mac which can be used in Terminal. It has now been developed under the name of Nano because of licensing problems of the original. This may be accessed by typing either pico or nano at the command line.Compared to emacs the user has a wealth of usable information (relatively speaking) displayed at the bottom of the screen, although some may not appear to be logical: Control G (not Control H) opens the Help file, for example. Although shown in the list of commands, there is no spell-checker installed for the version I am using. As with emacs and with locating files within Unix, it may be easier for the user to open a file (or folder location) by dragging it to the command line of Nano/Pico. Rather than "Save" a user needs to WriteOut a file, which in some cases needs permission to over-write a file. Exiting the utility is simply done, by using the Command + X keys.
Vi and VimThe text editor VIM is an IMproved version of Vi (VIsual editor). This may be accessed in Terminal on OS X by typing in either of those commands, as well as view, rvim or rview. We may also use ex which gives the options of "ex mode" or "visual mode". I must admit that I find Vim not as intuitive as I would like.
![]()
Commands are entered by typing a colon in the first column and a letter or word that relates to the action. To exit, we would type :q
:help
:help quickref There are a number of other files that may be useful:
![]()
man visudo Visudo which is structured like Vi and Vim, has a specific task here and should only be used if you absolutely know what you are doing: as with any of the commands, If in doubt, Don't.
Graham K. Rogers teaches at the Faculty of Engineering, Mahidol University in Thailand. He wrote in the Bangkok Post, Database supplement on IT subjects. For the last seven years of Database he wrote a column on Apple and Macs. |
|
For further information, e-mail to
![]() |
![]() |