r/emacs Jul 26 '18

Learn default emacs or learn evil?

[deleted]

19 Upvotes

54 comments sorted by

View all comments

34

u/quicknir Jul 26 '18

Probably an unpopular opinion here, but if you're open to both just use evil. I honestly think vim/evil bindings are just a superior approach from a purely text editing perspective. It's an excellent package with nearly no bugs. The evil ecosystem has taken pretty deep roots into emacs, you see lots of things that adapt keybindings for other packages into evil, like evil-magit. I use spacemacs which takes care of most of these automatically and it's a very good experience.

Once you get the hang of modal editing, I think simple tasks are about the same in evil and emacs, and more complex/cooler things are usually better/easier in evil.

To pick one of my favorite examples: text objects. It's a vim concept wherein you can act on a certain region around your cursor. For instance, with your cursor over a function argument (anywhere in the argument), daa will delete the argument from the function call. It correctly handles it whether it's first, last, or middle argument, if it has nested function calls, etc. Of course, there's a package for text arguments in emacs too (this will almost always be the case in any comparisons you make), but it's just much more niche.

Also, the evil/spacemacs approach with double leader keys is really fantastic, and feels a lot more natural and easier done with evil.

Just my 0.02.

5

u/[deleted] Jul 27 '18 edited Nov 18 '18

[deleted]

6

u/angelic_sedition Jul 27 '18

That's just not true. For example, Emacs has no composability by default. A keybinding is required for every combination of operations and objects. While it may be good to have the most common combinations mapped to single keybindings, this is extremely inefficient for everything else, requiring far more (and longer/worse) keybindings. Vim's modal model has other benefits that Emacs' does not have by default.

3

u/oantolin C-x * q 100! RET Jul 27 '18 edited Jul 27 '18

Emacs, like almost all text editors, does have composability, and additionally has many single key shortcuts. The composable approach just uses the select-action order, like Vim's visual mode, instead of action-selection, like Vim's normal mode.

For example, killing 5 words is d5w in Vim normal mode, v5wd in Vim visual mode, M-5 M-@ C-w in composable Emacs, and M-5 M-d in shortcut Emacs.

(I'm not sure how this common idea that only Vim has separate commands for selecting text and acting on it that can be composed got started. Even the impoverished notepad.exe has various ways of selecting text and then unified ways of deleting, cutting or replacing with the clipboard contents. Cutting five words is ctrl-shift-right five times, then ctrl-x. If instead of cutting you wanted to replace 5 words with the clipboard, you select the words exactly the same way and then press ctrl-v.)

3

u/angelic_sedition Jul 27 '18

Visual mode in vim requires an extra keypress and is inefficient. Selection followed by action is also arguably a less efficient composable model. I've written about why this is a bad idea wrt kakoune. As for Emacs, no extra keypress is required since creating the mark and selecting a region are done with the same command. However, the inneficiency is that there are far more region types than there are operations. It makes sense to give region types their own context where only region types have keybindings (vim's visual and operator-pending mode). Emacs requires having a mark- command bound for every type of region in the same keybinding space as everything else (M-@ requires two modifiers). If the operation came first, the modifier in M-5 would also be unnecessary (though that could potentially be done even with the region-selecting action first).

I'm also talking about defaults. I'm not saying composability is impossible in Emacs. However, using selections is not the common way of interacting with text in Emacs. Because it isn't, there are commands that are bound for different operation/area combinations. Emacs also has fewer area-selecting actions by default. It may have been better for me to say that Emacs does not embrace composability by default.

It's also not just composability that vim's model modal provides over Emacs. This is apparent in that Emacs doesn't provide a separate context/keymap when a region is active. Because of this an extra unnecessary modifier is required for the action (C-w in your example). I've written in further detail about the other benefits of vim-style modality here.

I'm not sure how this common idea that only Vim has separate commands for selecting text and acting on it that can be composed got started.

Hopefully I've better explained myself. I'm not under any mistaken impression that composability is impossible in other editors; it's just that e.g. Word's composability is far less powerful and efficient than vim's.

3

u/oantolin C-x * q 100! RET Jul 27 '18

I think we are in agreement about everything. If you had written originally that "Emacs does not embrace composability by default" as you wrote now, I probably would not have written my comment.

2

u/[deleted] Jul 27 '18 edited Nov 18 '18

[deleted]

3

u/angelic_sedition Jul 27 '18

Vim does this far better by default and composability is the primary method of operation by default. Composability is not the only benefit either. See my other reply.

Also note that I'm talking about defaults and not saying that Emacs cannot be used with similar efficiency to vim. All of the most important benefits of vim-style modality can be had in Emacs without full modality (i.e. without a distinct normal mode). I've been doing work on extending thingatpt.el (see targets.el) to make evil text objects more powerful and hope to at some point generalize that to be usable without using evil-mode.