Hacker News new | past | comments | ask | show | jobs | submit login

Well, maybe the author of that post just hasn't noticed the similarity between:

Vim normal mode grammar: command motion-or-textobject

Other editor's grammar: select-a-region command

(Also, Vim visual mode grammar: select-a-region command)

Emacs has lots of command that can select a region. They tend to be called mark-something. There are commands for selecting words, sentences, paragraphs, function definitions, S-expressions (the name comes from Lisp but they're defined to be something useful in every language, usually something like "any delimited construct in the language --strings, blocks, array literals, etc."). Once you select something you can apply many actions to it: you can delete it, uppercase it, rot13 it, sort the lines in it, wrap it in parenthesis, etc.

Maybe what tripped the author up is that additionally Emacs has other commands like kill-word, kill-line that are shortcuts for common combinations of a motion and a command. The author is correct in saying that these convenience commands are not composable, but they're nice shortcuts to have (and by the way, contrary to what the author says Emacs does have a kill-paragraph command).

So you to delete a word you can do:

Vim: dw

Emacs composable style: M-@ C-D (that is, mark-word delete- region[^1])

Emacs shortcut: M-D (kill-word)

Atom composable style: Option-Shift-f backspace

Atom shortcut: Option-d

(I got the Atom ones by Googling, I don't if they are right, but if they're not, I'm pretty sure correct ones exist: Atom has both a composable way and a shortcut.)

Vim propaganda should stop saying other editors lack composable commands. Even notepad.exe lets me use any of its paltry motion commands[^2] available to select something and then use a generic delete command to delete whatever I selected. "Composability" is the default mode of operation of most text editors.

Vim propaganda should focus instead on the very real advantages than Vim's command model has. For example:

- dot repeats the whole command/motion pair. This is fabulous!

- Vim has counts so you can delete 9 words just as easily as 3 words. (Emacs also has them, but lots of editors don't, and they're superhandy.)

- Vim has lots of little variations of the motions and textobjects so you can pick exactly what you need, other editors tend to have fewer. For example, for words, Vim has w, e, aw, iw (and probably others I'm forgetting) which are related but a little bit different.

(Also, personally I think Vim bloggers should recognize that those non-composable commands like kill-word are nice optional shortcuts, that are actually a tiny advantage other editors have over Vim. Try playing VimGolf in Emacs --using the nice vimgolf Emacs package, because of course Emacs has a package for that-- and you'll see what I mean.)

----

[^1] OK, techinically C-D is delete-forward-char in the default keybindings, but when a region is active it acts as delete-region.

[^2] It's limited to character, word and line, I think. But people forget even the lowly notepad.exe has word motions (all text widgets on Windows do).




It's an interesting point you make, that other editors also turn out to have some form of composability. However, the fact that this is the first time I've heard somebody talking about this might have some underlying meaning. Maybe vim is the only editor where people actually use the composability, because it's only in vim that it's actually usable :-)

In vim, the most common way to delete a word is also the composable way, and also the shortest (just two keys). In emacs, most people probably learn the shortcuts first, so they don't have the muscle memory for the composable style. The composable style is also two modifier keys longer. So in emacs, first you learn it the "regular" way, with all the shortcuts, and then when you want to learn composability, you have to relearn all sorts of basic things, and spend more keystrokes, to have that. In vim, you've learned some basic commands (dw, c$, yia, ...), and then I tell you about composability, and you understand how you can combine all those commands and movements you already know :-)


I agree with everything you said. It's certainly true that Vim (well, I guess this comes from vi) takes composability much more seriously than other editors.

I wish Emacs in particular took composability a little more seriously. Probably combining selecting an acting into a single repeatable command by default would be too un-Emacsy (after all, macros are very lightweight and there is evil mode), but it would be great to have all the fine-grained selection commands that Vim has. For example, AucTeX has a command to mark a LaTeX environment, but it also should have what Vim would call "inner LaTeX environment". As a more basic example, I wrote my own mark-line command because what I want to do with lines isn't always kill them! With builtins I think the best way to mark 5 whole lines starting from the one you're one is C-a C-SPC C-5 C-n, which is awful. With a mark-line command you just do M-5 M-L (depending of course on what you bind it too).

There have been attempts to bring better composability to Emacs besides Vi(m) emulators, in particular in a non-modal way. But the ones I've tried haven't fully convinced me. It's definitely possible to do it, but doing it properly might be a major undertaking. Maybe I should just start using evil again.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: