Difference between revisions of "Short Emacs Tutorial"

From dftwiki3
Jump to: navigation, search
(Minimalist Set of Commands)
(Playing with the Emacs Editor)
Line 40: Line 40:
  
  
   [aurora]$  '''getcopy fulghum'''
+
   [aurora]$  '''wget http://cs.smith.edu/dftwiki/media/fulghum.txt'''
  
  
Line 46: Line 46:
  
  
   [aurora]$  '''emacs fulghum'''
+
   [aurora]$  '''emacs fulghum.txt'''
  
  

Revision as of 18:48, 12 September 2015

--D. Thiebaut (talk) 18:41, 12 September 2015 (EDT)


Emacs


Reference


  • The page Emacs Quick Reference contains a list of most emacs commands you will ever need.
  • There are also many tutorials on the Web on emacs.


Minimalist Set of Commands


  • To create or edit a file called filename (replace with name you want to use for your file):
 emacs -nw filename

  • Then enter text as simply as possible.
  • To save the file and exit:
Control-X Control-C 

  • To erase a character: Control-d
  • To delete a line: Control-k
  • To bring a deleted line back: Control-y
  • To go down one page: Control-v
  • To go up one page: Esc-v
  • To go to the beginning of a line: Control-a
  • To go to the end of a line: Control-e
  • To replace a string (say "Better") with another string( say "Best" ):
  Esc % Return Better Return Best Return


Playing with the Emacs Editor


You will now get a copy of a file from your instructor's account, and edit it. The file is called Fulghum and is a short story from Robert Fulghum's book All I really need to know I learned in Kindergarten.

To get a copy of this file, type


  [aurora]$  wget http://cs.smith.edu/dftwiki/media/fulghum.txt


followed by the return key. Then edit the file with the command


  [aurora]$  emacs fulghum.txt


Simply work on the first paragraph of the file, and try to straighten it up. I have indicated below, on the right-hand side, which emacs commands you can use to fix the text on your screen.

Fulghum emacs.jpg

When you are done with the modification, or if you want to stop for right now and save your modifications, type C-x C-c, and press y when emacs asks if you want to save the file. Below is a summary of some useful emacs commands.

You should find some time this week to go to a lab and read the Emacs at Smith handout while in front of the terminal, on your own. This is the best way to test and learn the different features of the editor!

DEL/Shift Backspace Delete previous character
c-d Delete character at cursor
Esc-d Delete word
c-k Kill line
c-a Go to beginning of line
c-e Go to end of line
c-f Move cursor 1 character forward
c-b Move cursor 1 character backward
c-p Move to previous line
c-n Move to next line
c-x c-c quit emacs and save file
c-x c-s save file but remain in emacs
c-g GE OUT OF TROUBLE!