[Under GNU / Emacs papers Linux is a real notes of --Emacs IDE] Author: Ye Weibin MSN: fritz_yea@hotmail.comCopyright (C) Free Software Library, Org (http://yea.xiloo.com) in accordance with article GNU Free Document LIENCE is released, anyone can copy the original, reproduced, but please keep this statement. The author is not responsible for any result caused by this article.
10. Customize your Emacs. In fact, the debate about Emacs has never stopped. Some people insist that Emacs is a huge prehistoric creature, and some people insist on Emacs to be made by the art. In short, everything is surrounding its complexity. Undoubtedly, as a text editor, Emacs is indeed too large (it is more than 70 megabytes!). However, if Emacs treat Emacs as an environment (it is indeed an environment), it is very good, 70 megabytes of volume is nothing. As a regular user, I don't recommend you to use Emacs, vi is ok - but I am not not degrading Vi, the opposite, Vi is also a good editor for our respect - it will hide the complexity Behind the scenes, through various commands, and these orders we may never use it, so we don't have to pay attention to it, it is a small, concise and intuitive text editor. But if you are a programmer, or a system administrator, you will not be a beautiful interface, but a powerful function and efficiency. And this is Emacs to bring you. Ping, Emacs is not more than the other editor we usually usually used, such as UltraEdit, TextPad, Emeditor, etc., just when we use Emacs, you have to get a shortcut to the new adaptive Emacs. And it is this, giving a lot of gaury in front of the people who are discouraged, and they are rumored, and they will promote the "complex" of Emacs. In fact, once you are familiar with its shortcut, you can be as free as other software. (If you just write a few words, will you stick to the use of Word? If you want to write a C / C program, would you use Word? If you, I would rather use Notepad. When I first exposed the computer, I am still in the Black Side White DOS Time. I am amazed for the IDE environment in Turbo C. At that time, the clipping shortcuts were ctrl-ins, shift-ins, deleted a line of ctrl-y, until now I I can't help but want to use Ctrl-Y to delete a line. In fact, the unified software shortcuts are not MS, but WordPerfect, because of its popularity, so that the software has followed it, increase the affinity .f1 representative "help "It is to use it first. So don't complain that Emacs's shortcuts. Emacs can work out in a terminal environment without graphics, and it is the same below .ultraEdit Can?) Nonsense, the words returned. Our goal is to customize our work environment and make it best for our work. Therefore, we must first clarify some concepts. The concept of buffer buffer sounds very high, is actually a memory area for saving what we entered, you can understand it as a file. In Emacs, everything is carried out in memory until you press C-X C-S to save, your file will be changed. This is a universal text preservation strategy, almost all text editors work this. The window (frame) window is not Window, which refers to the area where the text you edited is displayed. This is similar to the small window where you open each file in UltraEdit. Mode mode (MODE) is the most important concept in EMACS, and the powerful feature of Emacs is basically provided by various modes.
Commonly used C / C modes, Shell mode, Perl mode, SGML / HTML mode, etc. Based on the concept, let us gradually study Emacs's IDE environment
10.1, files, buffers, and windows First, we can edit multiple files in Emacs. You can use C-X C-F to open (or create) files at any time. But by default, the editor automatically enters the new file window (all editors are like this). If we want to see two files at the same time (such as two files), we must first split the window. Use C-X 2 to grace the window. After the segmentation, you will be disappointed, and the content in the two windows is exactly the same (including your changes to either window, will be displayed in another window)! Yes, we just split the window, but there is no switching buffer, so it is still showing the contents of the original buffer. Use C-X o to switch to the window you want, then select the target file in the buffer list (C-X C-B). This way you can take two files in the same screen. You can also split the screen with a C-X 3 vertical, divided into two regions. The window can be divided in theory, as long as you feel that there are so many small windows meaningful (try to see, even Emacs will feel that you are so stupid), so you can divide the screen into a "product" shape, just press Press CX 2, CX 3. The concept of windows and buffers is completely different, so we can "close" windows, not "off" buffer, let it disappear from our sight. This is equivalent to the "minimal window" in the graphical environment. Use C-X 0 to close the current window, use C-X 1 to close other windows other than the current window.
The following list is very intuitive to show the keyboard operation of the window and buffer: ------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- --------------------- Window operation:
Function key function C-X 0 Deletes the current window and has no effect on the buffer. Note that this is a number 0. (Minimize Current Window) C-X 1 Delete all the windows other than the current, there is no impact on the buffer. (Minimize other windows) C-X 2 level segmentation of the current window. C-X 3 Segment the current window vertically. The C-X o switches the window (when there is only more than one window). Note that this is the letter O.
Buffer operation:
Function Key Function C-X C-F opens (created) files, create a new buffer. C-X C-S saves the current buffer to the file. C-X C-W Save the current buffer to another file (file saved as). C-X k off the current buffer. A list of C-X C-B buffers. You can use the arrow keys to select the buffer to switch. C-X C-C turns off all buffers and exits Emacs.
-------------------------------------------------- -------------------------------------------------- ---
10.2, mode Next Let's take a look at the mode in the Emacs (MODE). In Emacs, use a specific mode (Mode) whenever you edit a file. "Mode" in Emacs is different from "Mode" in VI. VI in the "command" and "editing" two modes, and only one mode in Emacs is the editing mode, and the commands in the emacs are completely completed. But what I said "mode" does not refer to this mode, but refers to various auxiliary environments in EMACS. When we edit normal text, use "TXT Mode", and when we write programs, such as the "SHELL (BASH) mode." When we start a file, Emacs will determine the type of file to automatically select the corresponding mode. Of course, we can also start various modes manually. Press M-X before entering the name of the mode. For example, start "C Mode", that is, M-X C-MODE. Press M-X directly, then press the two tab keys, you will get all the executable commands, which of course includes all modes. Therefore, you can't think of the name of a command, use this method. 10.2.1, C Mode In powerful C mode, we have powerful features such as "automatic indentation", "annotation", "pretreatment extensions", "automatic status". When we edit the code under "C Mode", you can use the Tab key to generate appropriate indentation, so that the code structure is clear and beautiful. We can also specify the rules of indentation. Emacs supported indentation rules include: BSD, CC-Mode, Ellemtel, GNU, Java, K & R, Linux, Python, Stroustrup, User, Whitesmith, specified by m-x c-set-style command. The source code must be well readable and must have a good comment. Use m-; you can generate a right indent annotation. In the form of "/ * comments * /" form, C-mode is a comment in the "// Comments" form in C mode. When we highlight a certain piece of text, press C-C C-C to comment out. Emacs can use C to preprocessing part of its running code to allow programmers to detect macro, conditional compilation, and the effect of include statements. For example, I imagine the following situation: 1. Enter the code you see at the top window. 2, highlighting a zone. 3. Press C-C C-E to call macro extension. Macro Expand Region can also be selected from the menu C. Emacs will create a spy hot window to display the result of macro extension. There is still a lot of features in the C environment in Emacs, which can help programmers accelerate the development process. When running in automatic state, and when the programmer enters the code, the C environment will automatically insert a new line, process indentation and complete other relevant tasks. In many cases, do not press the ENTEAR button when programming, the system will process. Press C-C C-a or run M-X C-Toggle-Auto-Stat to turn on the auto mode. When tapping the keyboard in this mode, the programmer will notice that whenever you enter the semicolon, the editor will automatically position the cursor to the next line and automatically indent. The final code seems to have no use of automatic mode; it just reduces the number of programmers to create file tap keyboard. If you want to turn off the automatic mode, you only need to press C-C C-a or run M-X C-Toggle-Auto-State, the system will restore the general state.
10.2.2, Compiler Emacs allows programmers to compile their own software in the Emacs environment. When doing this, the editor connects the compiler's output and program code. This means that programmers only need to click the error command (by pressing a carriage return), you can immediately locate those warnings and error messages. These options can be found in the Tools menu. When selecting Compile from the menu, Emacs requires the input to compile commands. If there is an Make file, you can accept the default settings. Otherwise, the programmer must fill in the compile command line for the correct compiler. If you encounter an error or warning at compile, Emacs will display them in separate windows. At this point, use Enter Click Error message to jump directly to the source code of the error. Sometimes, there will be hundreds of warning information in the output window; directly jump to the wrong place, can save a lot of time. As you can see, the default editorial command is called for an MAKE. Emacs can perfectly use Make and handle a lot of files, whether Emacs can support large projects, is completely unnecessary.
10.2.3, debugging many integrated development environments provide a debugger. Although most is just a limited debugger, Emacs provides a fully equipped excuse for the GDB debugger. When using GDB in Emacs, programmers can get all the standard features that GDBs are running at any other way. But it also includes some other properties obtained by interface enhancement. Using a GDB debugger in Emacs, you can observe how your code is running from beginning to end. This option is easier than the default GDB operation, and the default operation is just the command displayed. In addition, since the code can be re-compiled directly in the EMACS to run in the buffer, the code is changed to the code, recompile and run is a simple method. In order to adjust the debugger in the EMACS, select GDB in the Tools menu, the system prompt will appear, and enter the input to run files for debugging. When the name is entered, the GDB is called. I will see the same window as a standard GDB. When you place a breakpoint after the program's proper place, the source code window will have => tag points to point to the code of the breakpoint and highlight. The GDB window will no longer display the code. In the GDB window, you can use all common GDB commands. Using GDB in Emacs, programmers must learn any new commands. 10.2.3, another powerful function using tag Emacs is to use the ability to use the tag (TAG). According to the tag, the editor can distinguish which files belong to the same item. More importantly, the tag can also accurately point out what each file contains. For example, in the C program, the tag indicates that the file contains a specific function. When compiling files, you can jump directly to any function - regardless of the path of the file. In addition, you can use a set of files not just the current file. For example, a search command can work on a set of files. In order to provide this feature, Emacs needs to analyze files and saves tag information to be used. In general, implement this feature to use a file called Tags. Run the ETags program in the command line to create this file and give it the file name that you need index. For example: $ etags * .c etcus program analyzing source code and generating a tags file for easy use in Emacs later. Now you can use the TAGS option in the Tools menu to operate the files. You can use the find tag (m-.) To see what happened. For example, enter a function name, Emacs will jump directly to a file containing the function, and open this file, and locate the first row of the function; if the function appears in more than one file, You can use m- to continue to search for other files. 10.3, in Emacs, unique place in Emacs is that it can run the shell internally. There is no difference between the shell in the emacs, and the shell script we have written can run the test directly without having to exit Emacs. However, in Emacs's shell environment, some programs that need to be controlled to the console cannot be run, such as MC. This is what we can replace with Term mode, just run the m-x term-mode command. We have experienced the shell in Emacs in front, I will no longer repeat. 10.4, other, but not chicken rib EMACS integrates web browsers, mail readers, FTP, Telnet, newsgroup readers, version control systems, and more. It's too much, I will definitely I can't talk one by one. The best way to learn Emacs is "reading book practice", I just learn Emacs. You can also become an Emacs master. Conquering EMACS is not "unfinished mission".
10.5, tired, play games F10-> Tools-> Games, entertainment, our aim is - work and rest. [GNU / Linux actual combat "is all over. I hope this is a short five articles to play a bit, which doesn't invoicate my painful knock. Thank you for reading. :)