Using Emacs(转自:http://philip.greenspun.com/teaching/manuals/usermanual/emacs.html)

转自:http://philip.greenspun.com/teaching/manuals/usermanual/emacs.html

Using Emacs

by  Ed Hurley and  Andrew Grumet Note: If you're reasonably comfortable with Emacs you can skip this section. It only contains enough info to help someone who isn't comfortable find the information they need

If you've never used Emacs before you're in for a real treat. Emacs is a complete user environment with a simple but powerful windowing system disguised as a text editor. On the down side, all that power and sophistication implies some amount of complexity. Fortunately, most of what you will need to do can be accomplished with a small set of commands. Better yet, Emacs has an integrated help system which includes: a tutorial, key binding info, mode info, a command search (apropos), help for specific commands, and documention on other GNU packages which have been installed.

Your default path should be set up so that you can start Emacs in the following way:

   username@hostname:[dir]% emacs &
If your DISPLAY environment variable is set, this should start a new X window with emacs running inside it. The window will have 4 seperate areas. At the top will be a menu region, just below that will be a region referred to as the "buffer" (which consumes most of the window), and at the bottom two small regions which contain basic info (e.g. buffer name and mode), and commands.

If your DISPLAY environment isn't set, Emacs should run inside the xterm or shell in which you invoked it. Sometimes you actually prefer this, like when you're logged in from a machine which doesn't have an X server. You can force Emacs to start this way by using the "-nw" flag:

   username@hostname:[dir]% emacs -nw &

If you've never used Emacs before, it would be a good idea to go through the beginning of the online Emacs tutorial. To do this, start Emacs and type "Ctrl-h" followed by "t". (To type "Ctrl-h" you hold down the key marked "Ctrl" and type "h", then release the "Ctrl" key.)

Assuming you either know a little about Emacs already or have now gone thru the tutorial, there are a few other things you'll want to know about.

The first is how to run a shell inside Emacs. You do this with the command "Meta-x shell". ("Meta-x" or "M-x" is shorthand for holding down the "Meta" key and typing "x" while the "Meta" key is held down.) This will put the prompt in the bottom-most window, the command window. Now you just type "shell". Actually, you don't even have to type the whole thing. The Emacs command buffer has command completion. If you type "she" and hit the space bar it will complete the command for you. (Depending on how your Emacs and keyboard are set up, different keys may serve as "Meta". Sometimes it is the key marked "Alt". if there is no "Meta" or "Alt" key, instead press and release the escape key ("esc") key and then type "x".)

This will give you a shell inside of your Emacs window. You can do everything you would do in a normal shell, but you also have some additional features like Emacs copy and paste. You can kill the shell by typing a Ctrl-d at the prompt, or by invoking "Ctrl-x k" to kill the buffer the shell is running in.

Another thing you should know about is Dired. This is a quick way of navigating thru and manipulating a directory structure. You can get this via "Ctrl-x d"

Finally, once you become pretty sophisticated using Emacs, you might want to customize your Emacs environment. You can do this by modifying the .emacs file in your home directory.

Some commonly used Emacs commands

Abbreviations:
  • M-x = "meta x" = Esc, then x as described above (simultaneously pressing Alt + x, or "diamond" + x, works on some machines)
  • C-x = "control x" = Ctrl + x
C-shift-_                undo

M-shift->                end of buffer
M-shift-<                beginning of buffer

C-a                      beginning of line
C-e                      end of line
C-k                      delete from cursor to end of line

M-x shell                runs a shell inside emacs
M-p                      previous command (in shell mode)
M-n                      next command (in shell mode)

C-space                  set mark
C-W                      cut all text between mark and cursor
M-W                      copy all text between mark and cursor
C-y                      paste

C-x b                    change buffer
C-x C-b                  change buffer w/list of available buffers
                         (move cursor over the name of the buffer
                          you want and hit f)

C-x 2                    split the current buffer into 2, with one over the other
C-x 1                    1 buffer/window
C-x 3                    split the current buffer into two, with one next to the other
C-x o                    switch buffer

 


[email protected] Add a comment |  Add a link

你可能感兴趣的:(Using Emacs(转自:http://philip.greenspun.com/teaching/manuals/usermanual/emacs.html))