Hacker News new | ask | show | jobs
by falcolas 4399 days ago
You can apply modifiers to VI's composable objects. For example, you can prepend a 3 to the deletion operation, and delete three words, lines, or paragraphs.

You could replicate this by starting a selection and manually moving to the end (either by a combination of commands), but it looses its coherency as a single expression to be executed.

In the words of someone smarter than me, you have a conversation with vim - "delete three words", whereas you micromanage another editor - "start selection, move one word, move one word, move one word, delete".

2 comments

But, on the other hand, sublime/atom/... will give you immediate visual feedback about what it is going to delete (the marked range), whereas "delete three words" can potentially be open to ambiguity (plus you have to count words in advance...). For example, some editors consider my-function() a word, others stop the word at the "-" etc.

I understand why in some cases the kind of low level power you get with editors like vi and emacs etc is of an advantage, and I use vi regularly myself for basic editing on remote shells, but I am more of a visual person and I much prefer the usability over power approach.

I couldn't have said it better. Also, I have yet to see a more compelling example of clever composition in vim than "delete 3 lines" (which even I do when rarely using vim).
How about correct everything inside these parenthesis/brackets? Or indent everything within these brackets? Or do a search/replace over only the next paragraph? Or Title Case everything up to the next colon/semicolon/quote? Read the contents of file <x> into my current buffer? Format everything within these two matching quotes?

Every movement is composable with every action. There's a lot of movements, and a lot of actions. Delete three lines is the simplest possible command, but it's hardly the only one.

You can always just select stuff with your mouse and press the delete key. We're writing code, not prose, here. When was the last time you used paragraphs anyway?
Replace "paragraph" with "surround" (vim-surround), "argument" (argtextobj) or "indent" (vim-indent-object) then, which compose brilliantly with (c)hange/(d)elete + count + (i)nside/(a)round.
When writing documentation. The mouse + delete is not as easy when you're doing non-trivial movements, such as "replace everything between these matching parenthesis"

    ci(