A - A - A

Editing

 
Search

Because of the many uses to which ARMLinux can be put, it would not be practical in a short manual to provide a description of the rudiments of every program. We have therefore limited ourselves to an introductory treatment of text editing because this is a task which any user will need in their ARMLinux career.

There are literally hundreds of editors available including Vim, Jed, Joe and Emacs. Jed is a nice full-screen editor which is somewhere between MS DOS's Edit and Emacs whilst Joe will be appreciated by those who are used to the old Borland/WordPerfect control-key settings. Emacs, in contrast, has many of the characteristics of a complete working environment because it allows the user to do everything from writing letters to surfing the net. You can even play games within Emacs or indulge in a bit of psychotherapy by using the doctor package! We have not however, provided an Emacs tutorial in this guide so interested readers should refer to the section called Reading List in Chapter 12 or to http://www.gnu.org/manual/emacs-20.3/emacs.html/ where you can find a comprehensive Emacs guide.

Tip: If you decide to learn Emacs, you may see references to the META key in the Emacs literature which is equivalent to the ALT key on most keyboards. If you can't use ALT (it often doesn't work in terminals, for example) then you can use ESC to do the same job, but it should be released before the next keypress, not held down at the same time as it.

This section introduces you to:

  1. ae - the standard, tiny editor.

  2. Jed - a modeless editor which users of StrongED and Zap will find very accessible.

  3. Vim - an extremely powerful editor which can be found on all UNIX-like operating systems.

Editing with ae

ae can be activated by typing:

  1. ae at the shell prompt

  2. ae <filename> where you wish to work on a pre-existing file.

Two screens will then appear: an editing screen into which you can type and a help screen which provides a selection of useful commands. If you have used ae before, you can toggle the help screen on and off by typing C-x+C-h.

ae operates, like many Linux editors, via a series of control characters. C-x therefore instructs the user to depress the C (Ctrl) and x keys at the same time.

Typing a non-control character consequently has the the effect of placing the character which you have typed at the cursor. When you have finished your work, type C-x+C-s to save the current file to disc or C-x+C-c to save and exit.

ae is therefore very easy to use although its simplicity conceals a number of sophisticated features which include:

  • The ability to work with multiple buffers by using a root buffer and a series of virtual folds which correspond to the files to be edited.

  • User configurable key bindings.

For further information on ae, visit the editor's home page at http://www.interalpha.net/customer/nyangau/ae/platform.htm/.

Editing with Jed

Jed can be driven from a series of menus or with a combination of shortcuts. Jed is a modeless editor which means that you do not have to be in different modes to edit or insert text. Jed is also very easy to use and offers a range of facilities which include:

  • Colour syntax highlighting which can be useful for debugging your documents.

  • Special features which are activated on the basis of filetype.

  • Extensibility via the C-like S language.

Jed can be invoked by typing:

  1. jed at the shell prompt.

  2. jed <filename> at the shell prompt where you wish to edit a specific file.

  3. C-x+C-f in the mini-buffer. If you choose this command, you will see Enter Filename in the mini-buffer.

In addition to commands which begin with the Ctrl character, Jed also uses the ESC key for a number of commands. ESCn therefore means that you should press ESC before releasing it and pressing key n.

Assuming that you are working on the file readme.txt, type jed <readme.txt> at the shell prompt. You can then insert and edit text and move around the document by using the arrow keys. When you have finished the session, type C-x+C-s to save your document to disc. You can then exit from Jed by typing C-x+C-c.

The Jed screen contains a number of features which may be unfamiliar to you. These are:

  1. A Menu Bar across the top of the screen.

  2. A Mode Line containing useful information.

  3. A Mini-Buffer which is below the Mode Line.

The Menu Bar contains the menu options which you can use as an alternative to the keyboard shortcuts. To activate the Menu Bar, press the F10 key and select the menu which you require by using the arrow keys. The menu options should be self-explanatory with the possible exception of the Buffers option. A buffer is essentially a temporary workspace inside which you perform your work until you save any changes which are then written to the file.

In contrast, the Mode Line provides information about the document which you are currently working on. If you can see two asterisks (**) on the extreme left of the mode line, this is an indication that you have made changes to a document which has not been saved to disc. The mode line also tells you where you are in the document in terms of a line number as well as giving an indication of the current editing mode. Editing modes essentially help you to efficiently edit your documents by activating features like syntax colouring and specific formatting styles.

Finally, the Mini-Buffer is located below the Mode Line and echoes commands back to the user. Try keying in C-x+C-v to find an alternative file and you should get the idea but remember to hit the Return button after you have finished typing.

You should now know enough about Jed to perform simple editing. Jed also comes with its own form of on-line Help which can be activated by pressing C-h+C-h. A number of useful WWW resources are also available so point your browser to http://space.mit.edu/%7Edavis/doc/jed.html/ and http://www.geocities.com/mmarko.geo/jed/ Finally, take a look at Appendix A which lists some useful Jed commands. Please be aware however that the table uses commands which assume that Jed is using Emacs keybindings.

Editing with Vim

Vim is another editor which you can learn how to use. Vim also comes with an excellent tutorial which you can avail of by typing the following command at the prompt:

vimtutor

You can also save a bit of typing by using the filename completion facilities of the Bash shell. Simply type vim/usr/doc/vim and then press <TAB> so the shell fills in the remainder of the directory name, then you can enter the tutor and press <TAB> again to get the rest.

The tutorial will open from within Vim and you will then be able to learn enough to perform most of your editing activities. But just in case you want to familiarise yourself with Vim without recourse to the tutorial, what follows is an introduction to the editor's capabilities.

Vim is a modal editor which means that there are different modes for performing different tasks. Vim consequently operates in command mode when commands are being issued or in insert mode when text is entered on the screen. Although the method of issuing commands with a key press may seem counter-intuitive and positively archaic in comparison with more conventional point-and-click methods, it is actually a very efficient method of working and should be perservered with if at all possible.

In order to become conversant with Vim, we therefore suggest that you learn a few new commands per day and practice! Appendix B lists some of the common commands that you are likely to need.

Note: The user enters command mode by pressing the ESC key whilst insert mode can be activated by pressing i.

For more information on Vim, consult its home page http://www.vim.org/ or check out one of the many books which are available on Vi - Vim's predecessor.