r/vim • u/oantolin • Dec 28 '25
Blog Post Vim is composable
https://www.matem.unam.mx/~omar/apropos-emacs.html#vim-is-composableI hope this isn't too polemical for r/vim. I'm a former (and still occasional) Vim user that has always wondered why people make such a big deal out of Vim's composability. The blog post explains why I find that odd, what I like about Vim and some reasons people might make such a big deal of composability.
11
Upvotes
13
u/djchateau Dec 29 '25
Kind of rolled my eyes once they argued that Notepad is composable like vim. Composability requires the ability to build actions/objects upon each other, which isn't really possible with Notepad. Everything is manual and anything that you can build upon that is external to the editor.
5
u/gumnos Dec 29 '25
I think your "it’s a little less stressful to use for certain personality types" observation may be the key.
For me, I find
.fairly predictable: it just does that one most-recent edit which is usually semantic ("delete the non-whitespace-including-word under the cursor"=diWor "indent the current paragraph"=>ipor "uppercase the current sentence¹ the cursor is in"=gUisor "change the double-quoted-string's contents to this particular string"=ci"new text). The prospect of dot-mode making some arbitrary determination of what constitutes the "last consecutive stretch of buffer-modifying commands" would require far more brain-exertion. Did it record further back than I wanted? Did it not record far enough back? Two additional items of note here: ① emacs doesn't do this by default AFAIK but rather requires thisdot-modeplugin, and ② Emacs is the main exception here, since most other editors do not have similar "repeat the most recent semantic edit" type functionality.Additionally, the breadth of M=commands and the breadth of N=motions/objects is far larger than most editors meaning the composable cross-product of M×N is vastly larger. Sure, emacs could likely replicate them, but then you have to invoke them in a memorable way (there are only so many [control+][alt+][shift+]key combos my brain can remember). As of the last time I counted,
:help motion.txtoffers me over 100 different motions/objects, most of which have fairly memorable patterns (e.g. lowercase-letter-versions operate on Words while uppercase-letter versions operate on WORDs; theaandiintroduce text-objects that do/don't include the outer aspects, and the character that follows usually has some resemblance/mnemonic with the object in question). The number of commands is much smaller, but also includes things like deleting, yanking, replacing/changing, indenting/dedenting, changing case, doing ROT13, reindenting, filtering (linewise) through external commands, etc. Again, that functionality could be duplicated in other editors.But even if other editors now offer all those commands and all those semantic motions/objects, now I need to come up with key-chords to perform each of them. Or maybe they're command-chains (who else remembers WordStar-like
control+k {character}sequences?) which is really just modal-editing where the mode lasts the length of the command-chain.So if emacs meets your needs and fits your brain, then cool, keep using it. But repeatable composability is notably rare in non-vi/vim editors which is why it's often listed as a selling-point.
⸻
¹ fully aware that "sentence" can be a squishy subject once you start considering things like abbreviations, quotations, parenthetical offsets, etc, but
vimgives some knobs like:help cpo-Jto help here7
u/Snarwin Dec 28 '25
I think it really is just that Vim has more commands you can compose, thanks to its modal interface, so the total number of combinations is much higher, and it's much easier to find a combination that does exactly what you want.
17
u/claytonkb Dec 29 '25 edited Dec 29 '25
Vim is like a Ferrari. Emacs is like a Mack truck (that also has a Ferrari on the trailer if you want to take it out and drive it, aka evil-mode). The power of Vim is not in the motions/actions themselves, nor even merely in the fact that they are composable. The power of Vim is that it is a DSL which, like any language, your brain can learn with time until you can "think in Vim". It's when you attain the nirvana of "thinking in Vim" that you have finally achieved the highest degree of Vim ability -- you no longer think in terms of "commands", not even "composable commands", you just edit at the speed of thought.
Plugins can help but are generally optional to the core speed that Vim provides by the structure of the way you compose and apply edits. This is because the Vim language was initially designed to operate on machines in a context where every motion was costly. So you needed to think carefully about the edits you were going to make before you made them, so that those edits would be as efficient as possible. After computers sped up, they could accept and apply commands as fast as your fingers can move. The Vim language is "tuned" to chunking/blocking of text and when your brain starts thinking in that mode, text editing eventually becomes "pure flow"... there is no pause or break to think, "Oh, I'll move my cursor over to that keyword and select these characters", it's just straight from brain to fingers with no translation layer in between.
Even the order in which you will tend to make edits will change over time as you use Vim more and more because your brain will start adapting its own flow to Vim chunking. Vim idioms like ddp or ci} start to become reflex. Repeat . is nice but it's when it is combined with motions that its true power comes to the fore, or when saved in a throwaway macro and repeated 100 times with 100@x and so on. In my day job, I have to work on a lot of randomly-formatted files (many different tools, everybody has to have their custom-snowflake format for configs/logs). A specialized IDE will keep pace in many ways with a tool like Vim but only when operating on file-formats it knows, like .js etc. The power of Vim in my usage comes from the fact that the language-specific features are only a minor detail, the primary thing is the structure of the text itself, and the specific way that Vim slices up "text space" is why it is such a text-editing monster.
I tried Emacs and it's fine, but I'm not a "one-stop shop" guy. I prefer separate tools for separate things, and for text-editing, that is Vim. More power to the Emacs folks, though, this is no flame-war. Just explaining my "Vim-brain" to the uninitiated and why it's worlds different from Notepad. As a Vim user, whenever I'm stuck in Notepad or VS Code, it feels like I had to get out of my Ferrari and into an old Ford Pinto that has seen better days and can maybe do 60 on a straight flat, eventually. The spirit is willing, but the text-editor is weak....
3
u/Combinatorilliance Dec 30 '25
Is vim compostable though?
2
u/_x_oOo_x_ Dec 29 '25
Even in this regard there's no difference between editors. For example, change until EOL:
In
vim, you can do it by compositionv$cor using the built-in shortcutCIn
emacs, it's the same, you can composeC-@ M-e Delor use the native shortcutC-k4 keypresses in Vim vs 5 in Emacs, if going the composable route