Stanfo Programming Tutorial-Unix programming tools (IV)

Source: Internet
Author: User

Emacs

The following describes a text editor called Emacs, which is a free software provided by the GNU organization. It is a very good compiler and can be well integrated with other UNIX tools. Many editors have many reasons to explain how good they are, but we will not discuss this issue here.

If you want to start using Emacs to edit a new file or an existing file, just enter the following command at the Unix prompt...

EmacsFilename

FilemnameThe file to be edited. The Emacs version of X-Windows is called xemacs. If you want to use it... okay, let's take a look at the menus. The commands are basically the same, but you don't need to remember the interesting key combinations.

All the attractive editing commands, such as search-replace, can be implemented simply by entering some commands. There are two important keys you must remember: ^ X (press Ctrl and then X), [ESC]-X (Press ESC and then press X ), they are used to start typing important commands. For some historical reasons, in most emasc manuals, the ESC key actually refers to the "meta" or "M-" key. Therefore, you can find that [ESC]-X is equivalent to m-X.

Store the currently edited file. The command is ^ x ^ s. the exit command is ^ x ^ C (you will be prompted to save it ). the command to open another file is ^ x ^ F. this command can be used to open a file or create a new file. If you open many files at the same time, emacs will store them in different caches. To switch from one file to another (this is useful when writing. H files and. c files .), Command is ^ X-B (note that there is no CTRL), then you can jump to the corresponding file by entering the file name (there is a default file name for fast switching ). The arrow keys are generally similar to the mouse function. The following are some combined commands.


Run Emacs 

Emacs <FILENAME> runs Emacs. Make sure that you have not run Emacs in the background. If that is the case, you can use the FG command to wake up Emacs. Add "&" at the end of the command so that Emacs will not occupy shell.

^ Z suspends emacs-wake up with the % or fg command.

^ X ^ C Exit.

^ X ^ F load new files.

^ X ^ V load new files and unload the previous files.

^ X ^ s save the file.

^ X-K ends a buffer.


Move cursor

^ F moves forward a position.

^ B moves one position backward.

^ N move to the next row.

^ P moves to the previous row.


^ A move to the revelation line.

^ E move to the end of the row.

^ V FLIP down.

M-V pages up.


M-<start of moving to the file.

^ X-[move to the top.

M-> move to the end of the file.

^ X-] Move to the end of the page.


^ 1 re-edit the current row where the cursor is located.

^ X-o switch to another screen.

^ X-B is converted to another cache.


Search

^ S search for a string

^ R returns a string.

M-% find and replace


Delete

^ D Delete the character where the cursor is located.

^ K cut all characters from the cursor to the end of the line.

^ Y paste all cut characters. The ^ K, ^ y combination can be used to achieve simple cut-copy.


Region

Emacs defines the space between a tag and a vertex as a region. Use ^-space (CTRL + space) to mark the position of the cursor.

M-W replication area.

^ W cut area. Of course, you can also use ^ y to paste the cut area-this is the cut, copy, and paste method of the area.


Split screen

^ X-2 horizontal split screen.

^ X-3 vertical split screen.

^ X-1 closes all screens except the current screen.

^ The x-0 uses another screen as the only screen.

Other commands

M-$ check the spelling of the current word.

^ G is canceled, stopped, or returned to normal state in most cases.

M-x goto-lineNumMove to the corresponding row

^ X-u undo

M-x shell opens a shell in Emacs.

M-Q

Compile

M-x compile compiles code in the window. If you have set makefile, everything will be simpler.

^ C uses this command in the compilation window and it will move to the next compilation error. Great!

Get help

^ H Emacs help.

^ H t run Emacs tutorial.

Emacs provides you with the command complementing function. Input M-x space will list all Emacs commands. Emacs also has man help. You can run man Emacs in shell.


Print your source code

Here is a simple method to print the source code, using the "enscript" command. The code format is as follows:

Enscript-2grpsweet5 Binky. c Lassie. C *. h

This example is used to print Binky. C and Lassie. C and Their header files. The printer used is sweet5. you can change these parameters to suit your needs.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.