VI and Emacs

Source: Internet
Author: User

**************************************** **********************************

It's not long before I leave. WeLinuxThe version owner indicates that this week's user guide will be canceled. This guide is about some new tasks that can be completed by using vi.

Greg Menke issued the first top post. Use vi? How troublesome is it? He posted his steps:
1. Get a fish of any breed with a length greater than 12 inch.
2. Frozen for one night
3. Put it in front of the computer and run vi
4. catch the fish's tail until you decide to use EMACS. Because the scales splash around you and your head begins to hurt

Menke, of course, implies that not only are the users of vi and vi stubborn, but they refuse to admit that they abuse themselves, just like hitting your head with frozen fish.

It wasn't long before vi's advocates started to fight back. One of them suggested that Menke add this line to his step: Enter emacs before step 1, in this way, the loading of emacs may be completed at the end of step 1.

Is the EMACS editor slow?

Just as the tired army refused to give up the war in a short truce, vi and EMACS users in Linux, SAGE andOthersThe virtual community connected by computers is in constant cold war. Fortunately, the cold war will temporarily disappear for several months. However, once one party reveals slight contempt, the war will re-fuel the whole news group andEmail list. Out of their community culture, anyone in any camp who thinks they are using the best editor in the world and using other editors (especially those in the opposite camp) is a dumb, then give him enough ridicule and he will realize that he is wrong.

At present, the difference about which editor on Unix is the masterpiece of God is not so serious as to bring trouble to the world, as delicious is a fruitless war against Pepsi, just a small range of activists are shouting "Come on! ".

"As far as I know, the ratio of Emacs to VI is roughly 50/50 ,"Open SourceEric Raymond, an economist playing various roles in the hacking community, said in the email, "Pico, Joe, microemacs, and other editors have vanished from the statistics of the entire period." Raymond can personally date the VI/Emacs split back to 1985 and stipulates that, in all likelihood, it went on long before that.

As early as 1991, Raymond was in jargon file (Http://www.tuxedo.org/jargon/) Records the war between VI and Emacs, perhaps the ultimate collection of hacker terminology.

When asked, many people familiar with the two will say that their differences are in speed and functionality. VI users point out that they can quickly move and modify in the document, the advocates of Emacs boast their endless customization. VI users make fun of Emacs with too many unnecessary decorations; Emacs users make fun of VI, which is difficult to get started and has limited functions.

Therefore, the best editorTechnologyIs equivalent to "tastes great/Less filling? ", Yes, a few points. However, all religions or Wars teach us the lesson: the deeper you dig, the blackening the stream.

Of course, the argument is not completely meaningless. Our computer world is built by these editors from the very beginning. These editors that are transparent to end users have such loyal advocates that they are nothing more than a simple desire to do things in the most ideal way.

VI: Editor forgotten by time?

At first glance, from the appearance, VI is the kind of forgotten. It is not the kind of things you need to use when you open the terminal (for this idea, you 'd better use Emacs ). Even vim, the latest version of VI users, can be surprising (or frustrated) that they do not know how to start.

Even the webmaster of VI Lovers admitted that the learning curve was too steep. "Vi won't make you faster before you know more than 25 commands," says Thomer Gil, A Amsterdam local. He is now in the computer department at the Massachusetts Institute of Technology.

Gil's use of VIM was compared by his colleagues to "the savage waved axes and sticks ".

Among all the "disadvantages" of vi, the most significant difference is that you just want to enter something on the screen to start. Vi has two modes: one is the insert mode. You can type the text, and you can press the insert key to enter this mode. Another mode is the command mode. In this mode, you cannot type text, but only enter commands. You can press esc in the insert mode to enter the command mode.

Imagine that the user accidentally knocked on the esc key when using vi for the first time. In addition to finding that he could not input any text, he also found that the program made a variety of strange moves along with his keys.

In Jargon File, it is cold to point out that this feature of vi is "never-ending confusion for new users, because it either serves as a command when you want to input text, or vice versa, by default, the user is not prompted which mode the user is currently in."
"Multi-mode makes people feel weird ." Gil admitted.

Vi, written by Bill Joy in 1976, integrates two more primitive editing tools: ed and ex. Vi stands for "visual interface," which in 1976 was in quite the bleeding edge in computing, according to a Joy interview in Linux Magazine.

"I tried to make it available through a 300 baud rate modem, Which is why such odd commands exist. It works exactly through a modem and is full screen, "Joy says." So this editor is optimized to work when the screen is very slow ."

In that interview, Joy compared the development environment of EMACS and thought that EMACS was designed for optical fiber connection systems and a huge PDP-10.

"So they can have a lot of interesting commands, such as the shimbling on the screen. At this time, I am sitting in the room left behind by World War II in Berkeley, using the modem and terminal, these are just enough for the cursor to disappear from the bottom of the screen, "Joy said, maybe it sounds a bit jealous. "People do not know that vi is designed for a world that no longer exists ."

However, in the early 1980s s, when the network and processor were rapidly developing, the vi era was supposed to disappear, but it was never before. VI Pages lists the clones of nearly 30 types of vi, from elvis and VIM to those rarely heard such as WinVi and vigor.

Tim O 'Reilly, O' Reilly's planning in the company's Ask Tim column shows that the company has sold twice as many vi books as EMACS. Even more, at any time, in a vi-to-EMACS bullet ball game launched by o'reilly at some conferences, vi always has twice the number of EMACS volunteers.

What are they pursuing? John Arundel: "When a vi expert makes complex edits to a file, when his fingers fly on the keyboard and the text is like a screen, you will think that he is super powerful."

Gil on his websiteReleaseSome examples of this technique. "The key to vi is to combine specific actions (delete, copy to the buffer zone, change to uppercase, and so on) and move (to 25th rows, to the end of the document, to the next foo, to the second x in this row, and so on )."

"Huh ?" I sent an email to him.

Gil sends back an example: "if, for example, a document contains a line like this: 'a B c d e fg', the cursor is at B, in this case, you can type 'd/F '."

The first d indicates deletion and/indicates search. Therefore, this command indicates deletion from B to f.

"There are no special requirements for using these products... delete words and sentences and go back to the previous place. Oh, no, skip back, undo what I just did, and redo it again, "Gil wrote.

Gil makes sure you can do the same thing in EMACS, And then it needs to remember the clumsy "Ctrl-X Ctrl-c Alt-F4 key combination ".

Another trick that Gil shows is how VI users move data in files. "The clumsy way is to use the arrow keys; there are many other ways to move in a more advanced way ." Gil wrote. Advanced methods provided by vi Include jump to the position where the cursor is located last time or several times, jump to the next place of a specific word, and jump to the next sentence or chapter.

Even if dual-mode features become transparent to users. About a year ago, Jon Lasser and I discussed his recently published book, Think Unix. (He told me that the manuscript of this book was completely written in vi ). Finally, let's talk about vi. I started to complain about the two modes of vi.

Lasser explained that he didn't see any difference between using vi and using Word processors such as StarOffice or Microsoft Word. In general, when you move your hands out of the screen area, you cannot enter text. You actually switch from the insert mode to the command mode. "They are exactly the same thing ." He explained this.

As o'reilly wrote: "like many things on UNIX, it just looks hard ."

How luxurious is EMACS?

When vi's most loyal O 'Reilly wrote in Ask Tim that he initially switched from EMACS to vi only because his EMACS configuration file was corrupted. This is one of the countless attacks by vi users against EMACS.

EMACS and vi simple and limited commands are in stark contrast, because they have almost unlimited customization. People make it what it is, but this power is not necessarily the best for users.

As mentioned in Emacs-Beginner-HOWTO, EMACS can be an integrated development environment for text editors, email clients, news readers, word processors, script editors, and programming languages.

The key to achieving this is the multi-mode provided by EMACS. Each mode has a unique command set. Want to view emails? Enter the mail mode. To write a C ++ program, use the C ++ mode. Want to create a web page? The html-helper mode is suitable.

After understanding all this, you can also customize EMACS or even add new functions. This is usually done by modifying the Lisp code.

Vi users think that the exclusive feature of EMACS is that it should be a simple text editor and should not be done for users. A popular joke is that EMACS is an operating system bound with a text editor.

"EMACS is actually a standard project at the beginning," Guy Steele said in the email. He was one of the first authors of EMACS, and another author was Richard Stallman.SoftwareThe one from the foundation.

According to Steele, Stallman maintained a PDP-10's early Editor, TECO, which meant "Text Editor and COrrector ". Although fixed keys execute editing commands, Stallman creates a user-programmable table "so that the actions corresponding to each key are queried in the table," according to Steele. "One choice is to execute the TECO macro specified by the user ."

Using this macro function, users can bind their own set of macros to various strike key sequences through programming. However, when programmers cooperate in some programs, there will be problems, because they found that there were very few common key strike sequences between them.

"Communication between users began to be fragmented due to text (Program) Editing skills," Steele wrote. So Steele, along with David Moon and Stallman, started a project to integrate all ideas into a unified command set.

"I made a prototype on paper and carefully figured out the authors and users of various macro packages," Steele said in an email.

"I remember clearly," Dan Weinerb recalled. He is one of the alpha testers of EMACS. "This guy shows all the key bindings on his clipboard. This is a unified and standard key binding that he carefully collects from everyone ."

Several months later, Steele was busy finishing his doctoral thesis and handed over his work to Stallman. And the rest is history.

The flexibility from the very beginning gives EMACS advantages, as some hardcore users say.

"I think Emacs is like a Swiss Army knife in the editor," Debra Cameron said in an email that he is one of the co-authors of learning GNU Emacs and the owner of Cameron consulting. "It is a complete working environment and a tiny world. If you want it to do something, you may find that (after some searching) it has done. If you do not have one, you can expand it to do what you want ."

Can't we get along with each other?

How can we compare Emacs and Vi?

"I have seen a lot of skilled VI users demonstrate some pretty tips, but I still think VI is just an editor, although for some reason it is a great editor, "Cameron said in the email. "[It] always works in the same way. In this regard, it is like McDonald's; no matter which one you go to, it is always accurate and consistent ."

"You want an editor that can be modified at will to meet your needs and quirks. You can also do a lot of things, or you just want to edit files on any machine quickly ?" She asked. "For those who always want to move from one machine to another, this consistency is indeed an advantage ."

In other words, Emacs is equal to flexibility, while VI is consistent.

This is where things become dark.

"Of course, Emacs is much more complex than vi, but I don't believe it can do better in any useful place, but VI is part of a UNIX system and can work with other systems, "Jon Lasser retorted.

Note that for Lasser, "useful" means that vi allows you to read documents from other processes through the Unix pipeline, "just like using other UNIX Programs" he explained. Therefore, this mysterious sequence of keys "<ESC>: R! Ls <enter> "after entering in VI (Note: In command mode), read the output of" ls "-the file list in the current directory-to the buffer zone of VI. The pipeline of other UNIX programs also works.

To automatically edit a large number of files in VI, Lasser says that's why we have "SED, awk, and other UNIX text processing tools.

"Text processing is part of the UNIX design, while VI is part of the system," Lasser wrote.

Maybe the core issues of EMACS and vi are completely inconsistent with flexibility. After all, all editors provide flexibility, and vi also uses UNIX itself. However, the flexibility of EMACS is built on the system layer.

And, based on this fact, the only point of flexibility is to make work faster. If you want to process text directly without decoration, you can choose Pico, which only provides a blank screen without any confusing features, like vi or EMACS. However, both vi and EMACS share the same thing in that they provide some advanced methods to reduce the speed difference between the finger speed on the keyboard and the programmer's brain speed.

In other words, do these editors provide the same thing but require users to think differently? Vi needs patience to learn its odd ways of operation, and once you are proficient in them, you get the freedom of action on any UNIX system. EMACS gives you crazy freedom to define the equipment you think is appropriate, and if you are not careful, you will become your own prisoner.

On the journey of improving the efficiency of all excellent programmers, vi and EMACS users encounter each other at the intersection. They come from different directions. When they encounter each other, they usually throw stones to each other.

These are all good.

"I don't think there is a big difference in functionality. Both editors can do a good job, and it just comes down to what people learn first, "Gil writes. "Once most people have EMACS, they will teach others EMACS. Thus, most people use EMACS, and so on ."

Then the dispute will continue ......

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.