7 ms·
The way vim works is actually the opposite of what your brain wants, this is one of the reasons why learning vim tricks is hard. The vim model is "action-objec
by diegocg 5y ago
The way vim works is actually the opposite of what your brain wants, this is one of the reasons why learning vim tricks is hard.
The vim model is "action-object" (eg dw, delete word). A more natural, friendly and interactive model is the opposite, "object-action": first you select the text, your editor highlights the text, then you apply actions to the selection, one by one, and see what happens after each one. Because the text is highlighted beforehand and you see the effect of each action in real time, building chains of commands is much easier and friendly for novices. If you make a mistake, you see its effects and correct it immediately. In vim you have to build the command chain beforehand and calculate in your head what will happen. If you memorize the commands its fine, but if you don't, it's painful.
This "object-action" model is used by kakoune (https://kakoune.org/why-kakoune/why-kakoune.html https://kakoune.org/why-kakoune/why-kakoune.html), along with native multicursor support I have found it to be a great alternative after years of not being able to memorize vim commands. Documentation is scarcer at this point, though.
- benhurmarcel 5y agoSo Kakoune is like RPN (Reverse Polish Notation), and Vim is like Polish Notation then? For sure any user of RPN would agree that it makes more sense to type the operation after the object. Not sure how that translates to modal text editing though.
- oconnor663 5y agoI found that over the years, my Vim habits have naturally moved in an "object-action" sort of direction using visual mode. I think a lot of other Vim users end up doing the same. When I tried Kakoune for a few days, I found it difficult to adapt to the differences, but that's probably to be expected no matter what. One thing I particularly missed was g-v ("restore previous visual mode selection"), which I use constantly in Vim. There's a good chance it's doable, though, and I just didn't figure it out.
- chipotle_coyote 5y agoYou've oddly crystallized why Kakoune has so far failed to grab me! The description you gave of the actions one takes in editing makes sense: in most non-modal editors, you select the text you want to take actions on, then choose the action to take. But, I can do that in literally every modeless editor! That's the way essentially all of them work. But when people write of "Vim as a text editing language" as many comments here do, the action -> object model -- again, at least for me -- fits the pattern. We say "I'm going to the store," not "store I'm going to," unless Yoda we are. And, most programming languages that aren't purely object-oriented tend to follow a rough pattern of "action(parameter)". So in editors like Sublime Text (or VSCode or BBEdit or...) I tend to do editing in an entirely visual way, Vim approaches editing in a more language-based way, and when you describe edits in language, "[verb] the [noun]" is pretty natural.
- bombela 5y agoI tend to pick and measure a piece of wood before turning my saw and cutting. I say that I am cutting the wood. But I select it first before marking it and cutting it. I noticed that I use the visual mode of vim a lot. With easy motion to highlight words or other object boundaries to quickly jump to. I tried kakoune and liked it. But after 15y of (neo)vim it's hard to change. That plus how good You completeMe is for vim.
- addicted 5y agoWell, the reality is that WYSIWYG editing of all sorts is object oriented. You first select the object and then the action. So it’s not clear whether being more comfortable with selecting an object and then performing an action on it is innately easier for humans, or just what we’ve been conditioned to from using word processors, spreadsheets, or even GUI based file explorers. But if you look at command line usage, it’s the opposite. Every command first requires you to stare the command, and then the object to act on. I first type cd and then the folder I want to change directory to, compared to selecting the folder and then hitting enter/CMD+O/double clicking ont he GUI. But people who have used both the GUI and CMD line rarely ever find the order of operation to be a concern for them, so I suspect the object-verb verb-object difference in vim is just a matter of convenience.
- bombela 5y agoI do woodworking and construction work. In real life, I always must select first. Apply action second. So to me this feels more natural.
- addicted 5y agoI think you’re overestimating how well real life actions map to the object/verb dichotomy. So you’d say that it’s object first because you first get the wood and saw and then decide to saw the wood with it. I could argue it’s verb first because you first GET the wood and saw. I’m not saying that I’m right and you’re wrong. In fact, quite the opposite. My point is that I don’t think real life actions can be broken cleanly into object-verb or verb-object, in the first place.
- bla3 5y agoIf your brain prefers that order, you can emulate it in vim by doing v-movement-action, for example viwd to first select an inner word and then delete it.
- b0rsuk 5y agoI tend to do that whenever I'm unsure what my action will actually affect. Pressing one more key is a price I can pay.
- JoshTriplett 5y agoI do exactly this when I'm doing complex commands and want to select-verify-run. Most commonly, something like vi(c where I want to confirm how the parentheses are nested before the operation.
- omaranto 5y agoVim uses both models, it uses the object-action model in visual mode.
- pera 5y ago> The way vim works is actually the opposite of what your brain wants, this is one of the reasons why learning vim tricks is hard. Do you mean that you think "word change" instead of "change word"? To me this sounds like you have been programming in Java-like languages for too long :)
- robertlagrant 5y agoStrategy Pattern Change Factory get instance word
- jsjohnst 5y agoYou forgot the factory that builds the factory that builds the factory to call get on. I’m sure you’ll need a StringBuilder or two too! ;)
- b0rsuk 5y agoBefore I finished reading your first sentence, I knew you are a Kakoune evangelist. object-action may be a more natural order in some languages. I use a language which permits both. So I think you're overstating how much of a deal it is. That said, Kakoune has controversial design choices in a couple of areas: * no explicit select mode means not only you're selecting text all the time as you move your cursor (which can be annoying). More importantly, it means there are very few keys left on the keyboard for user defined commands. This comes up all the time on the forums whenever someone asks for a new function or an unused leader key. "Fewer modes" is not a virtue in itself, because modes have other benefits like taking the weight off keyboard. * Shell as a scripting language. Really. It's completely awful for maintainability. * I continue to argue that multi-cursors are a poor man's search&replace. It doesn't show off-screen matches by default, so you don't know if you're matching anything off-screen or not. There are Kakoune features I like very much, for example improved integration with commandline utilities. You can more easily use them to process the text inside editor.
- meepmorp 5y agoAre you making a general claim that the brain prefers object-action syntax vs action-object, or just in text editor commands?
- Firadeoclus 5y agoI think the only general claim that could be made is that the brain prefers to be certain of what's going to happen/what did happen. To get that you either need to have a good feel for where a motion is going to end up (which is harder the more inexperienced you are, and the more complex/farther the motion), or to get feedback. Personally, I also struggle with a relatively high rate of accidental (or mis-registered) key presses, or being in the wrong mode, which means that even if I have high confidence in constructing the right command in my head, my confidence in the right command being executed is significantly lower, and direct, always-on feedback thus feels enormously helpful to me.
- mcepl 5y agoWhenever you say words “natural”, or “friendly” you actually mean “what I am used to”. As the saying goes “Basically, the only ‘intuitive’ interface is the nipple. After that, it's all learned.” (Usenet discussion about Apple Macintosh). So, no, I spent couple of years struggling with non-modal editors, where I had that feeling all the time “I have no idea how to do it effectively in this $EDITOR, while I know five keypresses which would do it for me in vim.” Finally, I have liberated myself and switched back to vim.
- NateEag 5y agoIrrelevant nit, but: > “Basically, the only ‘intuitive’ interface is the nipple. After that, it's all learned.” The nipple is not intuitive for everyone. One of our children struggled mightily with the nipple and we had a miserable two or three months of breastpumping and finger-feeding before he finally figured it out.
- dotancohen 5y agoYeah, just wait until he gets to VIM in a few years.
- ajitid 5y agoHe later corrected it by saying: > There is no intuitive interface, not even the nipple. It's all learned.
- kerneis 5y agoFollowing-up on irrelevancy: what made you stick? We had the same experience, but gave up after 6 weeks because breastpumping was exhausting, and switched to bottles and artificial milk which our daughter loved immediately.
- NateEag 5y agoI think the belief (based on what evidence we're aware of) that breast milk is genuinely better for babies. My wife and I are both sort of gluttons for punishment if we're convinced something is the right path.
- nandhinianand 5y agoI suspect your hunch about object-action way brains work is very narrow and will not hold if extrapolated outside the western culture. My suspicion is based on a belief in [Sapi-Whorf hypothesis](https://en.wikipedia.org/wiki/Linguistic_relativity#:~:text=The%20hypothesis%20of%20linguistic%20relativity,relative%20to%20their%20spoken%20language https://en.wikipedia.org/wiki/Linguistic_relativity#:~:text=....). The need to reach of the object first is a very English specific language constraint afaik.