Using Emacs Last Revised: 4-19-00

Total Page:16

File Type:pdf, Size:1020Kb

Using Emacs Last Revised: 4-19-00 SSCC Pub.# 7-10 Using Emacs Last revised: 4-19-00 The GNU Emacs editor is the most commonly used text editor at the SSCC on UNIX. It is an extensible, customizable, self-documenting full-screen editor. Emacs is extremely powerful and has too many specialized commands and features to cover completely here. This handout serves only as an introduction, helping you get started using Emacs. A GNU Emacs Reference Card is attached to the end of this handout which lists many of the most frequently used Emacs commands along with a short description of what each command does. If you find you need to learn more after reading this handout, Emacs has a comprehensive online help facility where you can get more information. This help facility is described in this handout. Two books, Learning GNU Emacs, by Debra Cameron and Bill Rosenblatt and GNU Emacs Manual, by Richard Stallman provide a more comprehensive coverage and are available from Consultant for short term loan. Emacs is a modeless editor. This means that you insert text into your document without having to first enter a special insert mode. Likewise, you do not enter a special command mode when you need to issue a command. When you type an ordinary printable character such as the letter "k", it is inserted into your document; when you type a special character such as "Control-v" or "Meta-v", it is taken as a command (or the beginning of a command) to perform some operation such as deleting text or moving to the next line. Typing Emacs Commands Each command in Emacs has a formal name which is very long. Instead of typing out command names (which you could do), Emacs ties each command name to a short sequence of keystrokes starting with the Control key or Meta key, followed by one or more characters. This tying of commands to keystrokes is called binding. Commands shown in this handout use the following conventions: C-v Hold down the Control key and press v. M-v Hold down the Meta key and press v. On the NCD X-terminals, the Meta key is the Alt Function key. If your keyboard does not have a Meta key, you can use the Escape key instead. Rather than holding down the Escape key and pressing a character as you do with the Meta key, you need to press the Escape key, release it, and then press a character. To complete a command you usually need to press a carriage return: Note: If your keyboard has no Escape key, press C-[ (hold down the Control key and press [) instead. Release the key before pressing the next character in your command. The most commonly used commands are bound to the Control key. Slightly less commonly used commands are bound to the Meta key. Other commonly used commands are bound to C-x something, where something is some character you type in after pressing C-x. You can also get at commands by typing M-x long-command-name, where long-command-name is a command's formal name. Most Emacs users prefer to use the short sequence of keystrokes over the long command names because they are 1 SSCC Pub.# 7-10 easier to learn and take less time to type in. Emacs has a very helpful feature known as completion. For example, if you are typing the name of a file in the minibuffer (more about the minibuffer later) after issuing a command such as find-file (C-f), you need only type the first few letters of the name, enough to make a unique filename. Then press the Tab key and Emacs will complete the filename for you. Getting Into and Out of Emacs To enter Emacs, simply type emacs followed by the name of the file you want to edit. If you use a filename that does not exist, Emacs creates a new file and you will see a window similar to the one below: You simply enter text to begin your editing session. If the file you specify already exists, Emacs reads the file and displays it on the screen: You can also omit the filename when you invoke Emacs. In this case, your screen will look similar to the one below: 2 SSCC Pub.# 7-10 The message printed in the Emacs window disappears as soon as you type the first character. Emacs then puts you in an empty buffer (a buffer is a temporary workspace that may be saved later as a file) called *scratch*. Note: *scratch* buffers are not saved when you exit Emacs. Type C-x C–w to write this temporary buffer to a permanent file. The Emacs window contains three major areas: the largest area which takes up most of the window is where you enter your text. A cursor marks your position in the file. The cursor is also called "point" or "dot". The area at the bottom of the window which is in reverse video is called the mode line and provides information about the editing session: the name of the buffer being edited, the date, the mode you are in (Emacs has many different modes, each of which customizes Emacs for editing text of a particular sort), and where you are in the file. If you are at the beginning of the file, Emacs prints the word Top; if you're at the end, it prints Bot; if you are somewhere in the middle, it shows you a percentage; and if the entire file is visible on the screen, Emacs prints the word All. At the left edge of this line, you may see two asterisks (**). If the asterisks are there, this means that whatever you are editing has been modified since the last time you saved it. At the bottom of the window, below the mode line is the minibuffer. This is the area where Emacs echoes the commands you enter and where you specify filenames for Emacs to find, values for search and replace, and so on. To exit Emacs at any time, type C-x C-c. If you have made any changes that have not been saved, Emacs will prompt you, asking you if you want to save your changes. Getting Help Emacs has an extensive help facility, which you can activate by typing C-h. C-h t activates the Emacs tutorial which provides an excellent guided tour of most of the important Emacs features and concepts. However, do not use it for retrieving information on how to do something in particular. There are better ways of doing this. Pressing C-h k asks Emacs to give you documentation on whatever keystroke you type next. For example, if you type C-h k C-x i, Emacs gives you a description of the insert- 3 SSCC Pub.# 7-10 file command. Pressing C-h f asks Emacs to describe a function (really just a command's full name such as find-file). Essentially, C-h k and C-h f give you the same information; the difference is that with C-h k you press a key and ask what it does, whereas with C-h f you type a command name and ask what it does. To display the help options, type C-h three times. Emacs displays a window listing the options and providing a brief explanation of each one. Some options replace the window by a window of help information; some others split the screen into two windows. The screen always contains at least one window; the window containing the cursor is called the selected window. The following commands provide the window operations you will need in order to use the help system and exit from it when you are done: ! To switch windows when the screen contains more than one window, type C-x o. ! To scroll the selected window forward, type C-v. ! To scroll the selected window backward, type M-v. ! To scroll the other window forward, type M-C-v. ! To make all windows disappear except for the selected window, type C-x 1. ! To remove help information from the selected window, type C-x k. Probably the most useful form of help when you are first starting out is "apropos" help, which you can use to find out all the commands relating to a particular topic. You can get "apropos" help by typing C-h a. Emacs then asks you for some text that might appear in the names of the commands you are interested in. For instance, if you respond with delete, Emacs lists all the commands that have delete in their names along with their explanations. Editing Files Emacs achieves some of its famed versatility by having various editing modes in which it behaves slightly differently. Mode in Emacs simply means being sensitive to the task at hand. When you are writing, you often want features like word wrap so you do not have to press Return at the end of every line. When you are programming, the code must be formatted correctly depending on the language. For writing, Emacs has a text mode; for programming, Emacs has modes for different languages. Whenever you edit a file, Emacs attempts to put you in the correct mode for what you are going to edit. Fill Mode and Text Mode Before you start typing, look at the mode line at the bottom of the Emacs window. If the word Fill appears, you are in fill mode. In fill mode, when you type past the end of a line, 4 SSCC Pub.# 7-10 Emacs automatically starts a new line for you.
Recommended publications
  • 10 Keyboard/Keypad Page (0X07) This Section Is the Usagepage for Key Codes to Be Used in Implementing a USB Keyboard
    54 Universal Serial Bus HID Usage Tables 10 Keyboard/Keypad Page (0x07) This section is the UsagePage for key codes to be used in implementing a USB keyboard. A Boot Keyboard (84-, 101- or 104-key) should at a minimum support all associated usage codes as indicated in the “Boot” column below. The usage type of all key codes is Selectors (Sel), except for the modifier keys Keyboard Left Control (0x224) to Keyboard Right GUI (0x231) which are Dynamic Flags (DV). Note A general note on Usages and languages: Due to the variation of keyboards from language to language, it is not feasible to specify exact key mappings for every language. Where this list is not specific for a key function in a language, the closest equivalent key position should be used, so that a keyboard may be modified for a different language by simply printing different keycaps. One example is the Y key on a North American keyboard. In Germany this is typically Z. Rather than changing the keyboard firmware to put the Z Usage into that place in the descriptor list, the vendor should use the Y Usage on both the North American and German keyboards. This continues to be the existing practice in the industry, in order to minimize the number of changes to the electronics to accommodate other languages. Table 12: Keyboard/Keypad Page Ref: Typical AT-101 Usage ID Usage ID Usage Name Position PC- MacUNI Boot (Dec) (Hex) AT X 0 00 Reserved (no event indicated)9 N/A 4/101/104 1 01 Keyboard ErrorRollOver9 N/A 4/101/104 2 02 Keyboard POSTFail9 N/A 4/101/104 3 03 Keyboard ErrorUndefined9
    [Show full text]
  • The Linux Users' Guide
    The Linux Users' Guide Copyright c 1993, 1994, 1996 Larry Greenfield All you need to know to start using Linux, a free Unix clone. This manual covers the basic Unix commands, as well as the more specific Linux ones. This manual is intended for the beginning Unix user, although it may be useful for more experienced users for reference purposes. i UNIX is a trademark of X/Open MS-DOS and Microsoft Windows are trademarks of Microsoft Corporation OS/2 and Operating System/2 are trademarks of IBM X Window System is a trademark of X Consortium, Inc. Motif is a trademark of the Open Software Foundation Linux is not a trademark, and has no connection to UNIX, Unix System Labratories, or to X/Open. Please bring all unacknowledged trademarks to the attention of the author. Copyright c Larry Greenfield 427 Harrison Avenue Highland Park, NJ 08904 [email protected] Permission is granted to make and distribute verbatim copes of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections that reprint \The GNU General Public License", \The GNU Library General Public License", and other clearly marked sections held under seperate copyright are reproduced under the conditions given within them, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language under the conditions for modified versions.
    [Show full text]
  • Softwindows™ 95 for UNIX User's Guide (Version 5 of Softwindows
    SoftWindows™ 95 for UNIX User’s Guide (Version 5 of SoftWindows 95) Document Number 007-3113-007 CONTRIBUTORS Edited by Karin Borda and Douglas B. O’Morain Production by Carlos Miqueo © 1998, Silicon Graphics, Inc.— All Rights Reserved The contents of this document may not be copied or duplicated in any form, in whole or in part, without the prior written permission of Silicon Graphics, Inc. RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure of the technical data contained in this document by the Government is subject to restrictions as set forth in subdivision (c) (1) (ii) of the Rights in Technical Data and Computer Software clause at DFARS 52.227-7013 and/or in similar or successor clauses in the FAR, or in the DOD or NASA FAR Supplement. Unpublished rights reserved under the Copyright Laws of the United States. Contractor/manufacturer is Silicon Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94043-1389. TurboStart and SoftNode are registered trademarks of Insignia Solutions. SoftWindows is a trademark used under license. Silicon Graphics, the Silicon Graphics logo and IRIX are registered trademarks, and Indy, O2, and IRIS InSight are trademarks of Silicon Graphics, Inc. R5000 and R10000 are registered trademarks of MIPS Technologies, Inc. Apple and Macintosh are registered trademarks of Apple Computer, Inc. DEC is a trademark of Digital Equipment Corporation. WinPost is a trademark of Eastern Mountain Software. FLEXlm is a trademark of Globetrotter Software Inc. IBM is a registered trademark and IBM PC and IBM PC/AT are trademarks of International Business Machines Corp. Intel and Pentium are registered trademarks of Intel Corporation.
    [Show full text]
  • GSI Local Guide
    UNIX Primer GSI Local Guide GSI Computing Center Version 2.0 This is draft version !!! Preface: More than one year ago, we published our ®rst version of the Unix primer, which has been used in the meantime by many people at GSI and even in the outside HEP community. Nowadays, as more and more physicists have access to a Unix computer either via a X-terminal or use their own workstation, and as the installed computing power has increased by a large factor, we have revised the ®rst version of our Unix primer. We tried to re¯ect the changes in the installedhardware, like the installationof the 11 machine AIX cluster, and the installationof new software products, as the batch system for job submission, new backup and restore products and the graphics system IDL. Almost all chapters have been revised, and some have undergone substantial changes like the introduction, the section about experimental data and tape handling and the chapter about the editors, where more editors are described in detail. Although many topics are still missing or could be improved, we decided to publishthe second edition of the Unix primer now in order to give a guide to the rapidly increasing Unix user community at GSI. As for the ®rst edition, many people again have contributed to this document: Wolfgang Ahner, Eliete Bertulani, Michael Dahlinger, Matthias Feyerabend, Ingo Giese, Horst GÈoringer, Eva Hocks, Peter Malzacher, Udo Meyer, Kerstin Schiebel, Kay Winkler and Heiko Weber. Preface for Version 1.0: In early summer 1991 the GSI Computing Center started a Unix Pilot Project investigating the hardware and software possibilities of centrally operated unix workstation systems.
    [Show full text]
  • Summary Keyboard Mapping
    Technical Bulletin Product: RUMBA OFFICE 2.0 RUMBA for UNIX RUMBA for the VAX Version #: See above Host: UNIX, VAX Summary If you find that one or more of the keys you press in RUMBA for the VAX or RUMBA for UNIX doesn't produce the effect you expect, it may be that there is a mismatch between how the keyboard is mapped in RUMBA software and how the keys are mapped on the host. By remapping the characters that a key sends, RUMBA software can emulate most keyboards and be made to work with almost any application. When a key is pressed one of two things can happen. If the key defines a "local function," RUMBA software performs that function and nothing is sent to the host. One local function is the F2 or PrintScreen key. This function does not require host interaction. RUMBA software simply copies the information from the screen to the printer. If the key does not define a local function then RUMBA will send either a single character or a string of characters to the host. This document describes how to change the character or string of characters sent by RUMBA software when a key is pressed. It also covers some basic ways to determine what the host or application expects. To effectively fix key mapping problems, you will need to talk with your system administrator and possibly with the vendor of the host application you are using. Keyboard Mapping Host applications are written for a specific host keyboard. In the case of DEC and UNIX applications, this keyboard is usually a VT keyboard.
    [Show full text]
  • Keyboard Scan Code Specification
    Windows Platform Design Notes Designing Hardware for the Microsoft® Windows® Family of Operating Systems Keyboard Scan Code Specification Abstract: This specification details the PS/2 Scan Codes and USB Usage Tables that are validated for compliance to the Microsoft® Windows® Logo Program testing standard. This document details the alternative make and break PS/2 scan code and USB code response for the Windows Logo Key and Application Keys, plus Advanced Configuration and Power Interface (ACPI) power controls. This specification was previous published, with the same content, as “Windows Hardware Quality Labs Keyboard Specification” and also referred to as “Windows Keys Specification” and “New Keys Specification.” Revision 1.3a — March 16, 2000 Disclaimer: The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented. This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. Microsoft Corporation may have patents or pending patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. The furnishing of this document does not give you any license to the patents, trademarks, copyrights, or other intellectual property rights except as expressly provided in any written license agreement from Microsoft Corporation. Microsoft does not make any representation or warranty regarding specifications in this document or any product or item developed based on these specifications.
    [Show full text]
  • Xterm Control Sequences
    Xterm Control Sequences EdwardMoy University of California, Berkeley Revised by Stephen Gildea XConsortium (1994) Thomas Dickey XFree86 Project (1996-2003) Definitions c The literal character c. C Asingle (required) character. Ps Asingle (usually optional) numeric parameter,composed of one of more digits. Pm Amultiple numeric parameter composed of anynumber of single numeric parameters, separated by ;char- acter(s). Individual values for the parameters are listed with Ps . Pt Atextparameter composed of printable characters. C1 (8-Bit) Control Characters The xterm program recognizes both 8-bit and 7-bit control characters. It generates 7-bit controls (by default) or 8-bit if S8C1T is enabled. The following pairs of 7-bit and 8-bit control characters are equivalent: ESC D Index(IND is 0x84) ESC E Next Line ( NEL is 0x85) ESC H TabSet ( HTS is 0x88) ESC M Reverse Index( RI is 0x8d) ESC N Single Shift Select of G2 Character Set ( SS2 is 0x8e): affects next character only ESC O Single Shift Select of G3 Character Set ( SS3 is 0x8f): affects next character only ESC P Device Control String ( DCS is 0x90) ESC V Start of Guarded Area ( SPA is 0x96) Xterm Control Sequences C1 (8-Bit) Control Characters ESC W End of Guarded Area ( EPA is 0x97) ESC X Start of String ( SOS is 0x98) ESC Z Return Terminal ID (DECID is 0x9a). Obsolete form of CSI c(DA). ESC [ Control Sequence Introducer ( CSI is 0x9b) ESC \ String Terminator ( ST is 0x9c) ESC ] Operating System Command ( OSC is 0x9d) ESC ^ Privacy Message ( PM is 0x9e) ESC _ Application Program Command ( APC is 0x9f) These control characters are used in the vtXXX emulation.
    [Show full text]
  • Teemtalk for Unix User's Guide V
    TeemTalk® 5.0 for Unix User's Guide Trademarks TeemTalk is a registered trademark of Neoware UK Ltd. IBM is a registered trademark of International Business Machines Corporation. X Window System is a trademark of the Massachusetts Institute of Technology. All other product names are trademarks of their respective manufacturers. Copyright © 2004 by Neoware UK Ltd. All rights reserved. Before reproduction of this material in part or in whole, obtain written consent from Neoware UK Ltd. Neoware UK Ltd, The Stables, Cosgrove, Milton Keynes, MK19 7JJ, UK Tel: +44 (0) 1908 267111 Fax: +44 (0) 1908 267112 Contents Contents Introduction ....................................................... 1-1 TeemTalk & The X Window System .............................................. 1-1 User's Guide Overview .................................................................. 1-2 Terms & Conventions .................................................................... 1-3 Getting Started.................................................. 2-1 Initiating A Telnet Session ............................................................ 2-1 Selecting & Using Window Elements ............................................ 2-3 The Title Bar ..................................................................................... 2-3 The Menu Bar .................................................................................... 2-3 Window Resize Commands ....................................................... 2-4 The Soft Buttons ...............................................................................
    [Show full text]
  • 10 Keyboard/Keypad Page (0X07) This Section Is the Usage Page for Key Codes to Be Used in Implementing a USB Keyboard
    Universal Serial Bus HID Usage Tables 53 10 Keyboard/Keypad Page (0x07) This section is the Usage Page for key codes to be used in implementing a USB keyboard. A Boot Keyboard (84-, 101- or 104-key) should at a minimum support all associated usage codes as indicated in the “Boot” column below. The usage type of all key codes is Selectors (Sel), except for the modifier keys Keyboard Left Control (0x224) to Keyboard Right GUI (0x231) which are Dynamic Flags (DV). Note A general note on Usages and languages: Due to the variation of keyboards from language to language, it is not feasible to specify exact key mappings for every language. Where this list is not specific for a key function in a language, the closest equivalent key position should be used, so that a keyboard may be modified for a different language by simply printing different keycaps. One example is the Y key on a North American keyboard. In Germany this is typically Z. Rather than changing the keyboard firmware to put the Z Usage into that place in the descriptor list, the vendor should use the Y Usage on both the North American and German keyboards. This continues to be the existing practice in the industry, in order to minimize the number of changes to the electronics to accommodate other languages. Table 12: Keyboard/Keypad Page Ref: Typical AT-101 Usage ID Usage ID Usage Name Position PC- Mac UNI Boot (Dec) (Hex) AT X 0 00 Reserved (no event indicated)9 N/A √ √ √ 4/101/104 1 01 Keyboard ErrorRollOver9 N/A √ √ √ 4/101/104 2 02 Keyboard POSTFail9 N/A √ √ √ 4/101/104 3 03 Keyboard
    [Show full text]
  • Learning GNU Emacs Other Resources from O’Reilly
    Learning GNU Emacs Other Resources from O’Reilly Related titles Unix in a Nutshell sed and awk Learning the vi Editor Essential CVS GNU Emacs Pocket Reference Version Control with Subversion oreilly.com oreilly.com is more than a complete catalog of O’Reilly books. You’ll also find links to news, events, articles, weblogs, sample chapters, and code examples. oreillynet.com is the essential portal for developers interested in open and emerging technologies, including new platforms, pro- gramming languages, and operating systems. Conferences O’Reilly brings diverse innovators together to nurture the ideas that spark revolutionary industries. We specialize in document- ing the latest tools and systems, translating the innovator’s knowledge into useful skills for those in the trenches. Visit con- ferences.oreilly.com for our upcoming events. Safari Bookshelf (safari.oreilly.com) is the premier online refer- ence library for programmers and IT professionals. Conduct searches across more than 1,000 books. Subscribers can zero in on answers to time-critical questions in a matter of seconds. Read the books on your Bookshelf from cover to cover or sim- ply flip to the page you need. Try it today with a free trial. THIRD EDITION Learning GNU Emacs Debra Cameron, James Elliott, Marc Loy, Eric Raymond, and Bill Rosenblatt Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo Learning GNU Emacs, Third Edition by Debra Cameron, James Elliott, Marc Loy, Eric Raymond, and Bill Rosenblatt Copyright © 2005 O’Reilly Media, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
    [Show full text]
  • Xemacs User's Manual
    XEmacs User's Manual July 1994 (General Public License upgraded, January 1991) Richard Stallman Lucid, Inc. and Ben Wing Copyright c 1985, 1986, 1988 Richard M. Stallman. Copyright c 1991, 1992, 1993, 1994 Lucid, Inc. Copyright c 1993, 1994 Sun Microsystems, Inc. Copyright c 1995 Amdahl Corporation. Permission is granted to make and distribute verbatim copies of this manual provided the copy- right notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the con- ditions for verbatim copying, provided also that the sections entitled \The GNU Manifesto", \Distribution" and \GNU General Public License" are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that the sections entitled \The GNU Manifesto", \Distribution" and \GNU General Public License" may be included in a translation approved by the author instead of in the original English. i Short Contents Preface ............................................ 1 GNU GENERAL PUBLIC LICENSE ....................... 3 Distribution ......................................... 9 Introduction ........................................ 11 1 The XEmacs Frame ............................... 13 2 Keystrokes, Key Sequences, and Key Bindings ............. 17
    [Show full text]
  • THE PERFECT KEYBOARD for GNU EMACS and XML: the SYMBOLICS/APPLE MACIVORY John Bear November, 2002
    THE PERFECT KEYBOARD FOR GNU EMACS AND XML: THE SYMBOLICS/APPLE MACIVORY John Bear November, 2002 This paper has been in preparation for too long. I finally decided (May 31, 2005) to post it as is, figuring something is better than nothing. This article is for two groups of people: people who use Emacs and people who don't. My purpose is simple. I want somebody, Apple or Symbolics, or some third party, to bring back the Symbolics MacIvory keyboard. The way I hope to accomplish this is to let people know that it exists, and that it's perfect for Emacs and XML, and merely damn good for everything else. If enough of us make it clear there's a market, I figure someone will start selling them again. We Emacs users win, and so does Symbolics or Apple, or whoever starts selling them. Much of this article is about how the keyboard was designed to work with Emacs, but the rest is about how it out-performs other keyboards even for normal typing tasks. The MacIvory was an Apple Macintosh computer that had a Symbolics Lisp machine inside, and was sold around 1987. It came with a Symbolics keyboard that had the same layout as earlier Symbolics keyboards, but with keys that were easier to press. It was designed (as were all Symbolics keyboards) to be used with the Zmacs editor, a version of Emacs. Although the keyboard is not a split keyboard, it was designed with kinesiology in mind and deserves to be considered an ergonomic keyboard.
    [Show full text]