|
|
Two editors are available on MMM's workstations, vi, the standard Unix editor, and GNU Xemacs, commonly called Xemacs, a public-domain software package widely available on a number of platforms. Both are used for editing ASCII files; they cannot edit binary or special files such as FrameMaker files.
There are benefits to learning both of these editors. Xemacs, a powerful screen editor, provides more flexibility, but is not available by default on all Unix platforms. Since vi is available with all Unix workstations, it is important to learn at least the basic commands for editing a file in vi. This chapter provides basic information on both editors.
vi filename
arrow keys Moves the cursor right, left, up, or down. $ Moves to the end of line. ^ Moves to the beginning of line. H Moves cursor to top of screen. L Moves cursor to bottom of screen. nCTRL-f Scrolls file forward one screen. nCTRL-b Scrolls file backward one screen. w Moves forward one word. b Moves backward one word. nG Moves to line number n. /string Searches forward for string. ?string Searches backward for string. nx Deletes character(s) at cursor. ndd Deletes current line(s).
i Inserts text before the cursor. a Appends text after the cursor. I Inserts text after the current line. A Appends text before the current line. o Opens blank line after current line. O Opens blank line before current line. ESC Terminates input mode.
:q! Exit without saving changes. ZZ Exit saving all changes :w! Write the file to a file of a different name before exiting.
vi -r filename
:set list This command shows what has happened. :%s/ *$// This command trims lines. The spaces are important.
The public-domain GNU Xemacs editor, was developed at MIT to run on Unix systems. Xemacs is a powerful editor that provides the capability to customize the user environment by programming the keypad and various other keyboard keys. Since different sites will program their keyboards to meet their specific requirements, it is recommended that users learn the generic Xemacs commands as these will be common among various Unix platforms. Users may set up their own key bindings if they want, however, these will not be supported by the systems group. This section will describe some of these basic commands. In addition, a quick reference guide to all the Xemacs commands can be obtained from the division documentation library.
To use the custom key bindings for the MMM environment, copy the file /usr/local/skel/.xemacs into your login directory.
Please note the following conventions used in the control sequences given throughout this chapter.
C- Press the CTRL key along with the letter indicated. M- Press the ESC key along with the letter indicated. (The ESC key may be the F11 key on some DEC keyboards, rather than the key marked ESC.)
1. To enter Xemacs and go directly into a specific file, type xemacs filename If the file name you enter does not exist in your directory, Xemacs will automatically create a new file.Alternatively, if you are not working on an X Windows device, you can enter
xemacs -nw filename OR 2. To enter Xemacs without specifying a file name, simply type xemacs You are placed into a generic "scratch" file. At this point, you can read a file into Xemacs by entering C-x C-f. At the prompt, enter the name of the file.
1. To temporarily suspend Xemacs, press C-z This will temporarily exit you from the file you were editing, and put your editing session into Unix background mode, so that you can execute Unix shell commands. To resume your editing session, type the Unix command, fg at the prompt. You will then be placed back in the file at the point where you were editing when you entered C-z. 2. To permanently exit Xemacs, enter C-x C-c You will then be prompted to save changes made in the current file and any other Xemacs files you may have been editing.
C-h b Get current key bindings. C-x 1 Get rid of Help window. M-C-v Scroll through help window. C-h a Apropos; show commands matching a string. C-x k Return from tutorial to original file. C-x b Return from tutorial (buffer) to original file (buffer).
C-s Search forward. C-r Search backward. C-a Go to beginning of line. C-e Go to end of line. M-< Go to beginning of buffer. M-> Go to end of buffer. C-v Scroll to next screen. M-v Scroll to previous screen. C-d Delete a character. M-d Kill a word. C-k Kill to end of line. C-y Yank back last thing killed. M-% Interactively replace a text string. SPC Replace this one, and go on to next. DEL Skip to next without replacing. ! Replace all remaining matches.By default, Xemacs functions in insert mode. To enter overwrite mode, type M-x overwrite-mode. Thereafter, type this command to toggle back and forth between the two modes.
C-x 5 Split screen into two horizontal windows. C-x 2 Split screen into two vertical windows. C-x o Switch between windows. C-M-v Scroll through other window. C-x 0 Delete current window. C-x 1 Delete other window.
xemacsYou are placed in a blank Xemacs "scratch" file. Once in this file, enter
M-x diredThe name of your current directory appears at the bottom of the screen. To edit this directory, press RETURN. To edit a different directory, backspace and type the name of the desired directory, then press RETURN. A listing of the files in the specified directory appears.
You can now move through this list using the arrow keys. The following commands are available.
n Move down to the next file (the down-arrow key works as well). p Move up to the previous file (the up-arrow key works as well). d Flag file on this line for deletion. (A "D" will appear next to the file.) To actually delete the flagged files, use the x command. u Remove deletion flag for file on this line. # Flag all auto-save files (files that start and end with #) for deletion. ~ Flag all backup files (files that end with ~) for deletion. x Delete files that are flagged for deletion. (This command first lists all the files that are marked for deletion and asks you whether you want to delete them.) c Copy file on current line. (You must supply a new file name.) r Rename file on current line. (You must supply a new file name.) v Visit file on current line. (You can move around in the file, but you cannot change it.) o View file on current line in another window.