ViAndEmacs

Last edit

Summary: Rückgängig gemacht auf den Stand vom 2013-08-24 11:21 UTC

Changed:

< Beyond Emacs considering line numbers as evil, Emacs emphasizes moving by syntax (paragraph, word, page), using the UniversalArgument with any command, and of course offers WikiModes facilities like IncrementalWikiModes or OccurMode.

to

> Beyond Emacs considering line numbers as evil, Emacs emphasizes moving by syntax (paragraph, word, page), using the UniversalArgument with any command, and of course offers search facilities like IncrementalSearch or OccurMode.


Vi vs. Emacs – a holy war! See the Jargon File entry holy-wars [1].

There’s an almost religious debate about the pros and cons of Emacs and Vim. How does Emacs make life easier?

Some favorites from the SiteMap: CategoryProgrammerUtils, CategoryGnus, CategoryJournaling, CategoryHypermedia, EmacsLisp, EmacsNiftyTricks#Programming, EmacsNiftyTricks, WhyUseEmacs.

With Emacs, you have only one set of keystrokes for text editing that you need to memorize – anywhere and everywhere. Emacs gives you an environment where you can do that: coding, writing, compiling, debugging, chatting, web browsing, calendar, diary, todo, address book, blogging, ….

If you want to be really fast about editing text only, then most editors are very similar once the necessary shortcuts and commands have been learned. In the end, the slowest link in the chain is usually the user doing the typing. When you want to go beyond simple text editing, however, Emacs will grow with you. See EmacsDefense.

Emacs Humor

EveUsesEmacs

You’ve got to see the funny side in a page purportedly advertising Emacs being made up in goodly amount with vi advice.

Emacs has a great heart. For example: Emacs has been delivered with a vigorous pamphlet for ed for several years now. See share/emacs/<version-number>/etc/JOKES. See TheTruePath, AddictedToVi, and EndorsedByAAOS.

Emacs keybindings for Vi users:

CommandKeystrokesWhat you are thinking
QuitCtrl-x Ctrl-c“What! Emacs is the default editor? Abort!”
Abort current commandCtrl-G or Ctrl-] (repeat as needed)“Escape! ESCAPE! Stop printing ESC at the bottom!”
Enter vi emulation modeMeta-X viper-mode RET“Please, please, let me just change these two lines…”
Enter vi emulation mode (maybe)Alt-X viper-mode <ENTER>“What the heck is a META key? It is what Alt MAYBE is…”
Enter vi emulation mode ESC X viper-mode <ENTER>“What the heck is a META key? It is what ESC normally is…”

For a serious tip sheet for Vi users, see Google:grok2.

Getting the best parts of Vim and Emacs

(sigh) I’d love to combine emacs and vim together. I love the power and sheer number of useful things in emacs, but some things about it drive me crazy - why oh why is emacs clone of vis setnu mode so appalling bad? Every editor I’ve ever used has done LineNumbers easily, so why does emacs do it slowly and frequently mess up the numbering? It can’t be that hard. On the other hand, each time I’ve tried to use vim as my editor I’ve ran into problems, like tab completion not popping up a directory entry, or it’s bizarre buffering system.

In short, emacs is cool because it does everything, and because you can normally guess or tab complete the name of a function, then bind it to whatever key you like… the online help is good too.


[Suggestion] Look no further than Viper, the standard emulator of Vi in Emacs. Viper combines the advantages of Emacs and Vi and lets you use both. Btw, Viper has an analog of the * key in Vim both using a mouse and a key.


I don’t mean to be facetious, but what do you need to use LineNumbers so often for? With things like M-x grep and M-x compile combined with C-x `, as well as M-x occur, emacs will usually take you to the line you want automatically without any need for you to type in explicit line numbers.

Well, some people including myself just generally like line numbers. They make it easier to differentiate between similar yet different pieces of code.

The current line number is always in the mode-line. Lot’s of people typically bind goto-line to a keyboard shortcut, for example:

(global-set-key “\C-cg” ‘goto-line)

in your .emacs will bind the goto line function. to C-c g. Emacs’ philosophy is that line numbers are generally evil (sometimes a necessary evil, but an evil all the same) since they change frequently and viewing line numbers shrinks screen real-estate and degrades readability. If you think otherwise, Emacs is probably not the best editor for you.

The only reason I ever needed to jump to line numbers in Emacs was to find the line number from compilation errors in source code. That was before I knew CompilationMode could jump right to an error.

Beyond Emacs considering line numbers as evil, Emacs emphasizes moving by syntax (paragraph, word, page), using the UniversalArgument with any command, and of course offers search facilities like IncrementalSearch or OccurMode.

After finding this out, I haven’t needed goto-line, since. I’m glad I never bound ‘C-c g’ in my .emacs file. If I by chance I do need it, ‘M-x goto-line’ is easy enough.

Emacs 22 binds goto-line to ‘M-g g’ and ‘M-g M-g’.

Line numbers (plural) are indispensable when you can jump to them quickly. Emacs’ ‘M-g g 42 RET’ doesn’t quite compare with 42G or :42 in vi (Viper).

I hope line numbers will be done in C code at some point …

As a vi user, I thought I’d pop in and point out that emacs’ ‘M-g g 42’ is only a single keypress more than either 42G or :42, so perhaps the previous is not a very good argument. Still, I keep line numbers on at all times and even resize my terminal to 88 cols so that I can have my sweet, sweet line numbers and keep 80 cols of editable space--they’re kind of nice when you’re used to them.

You also have to press enter (2 keybpresses more than 42G). Furthermore the emacs binding is a Meta key chord, which makes it very uncomfortable (I think).

Typing M-4 M-2 M-g M-g has the same effect

Or if you hate meta: ESC 4 2 ESC g g


CategoryHumor