by grogers · 16y ago · 0 comments
Moreover, the command cib itself is built from composeable parts - c (not sure what the mnemonic for this is but its delete then enter insert mode), i (inner), b (block of parens). There are several commands besides c - d (delete), < (left indent), = (auto indent), etc. And these compose with any motion, eg gg (goto line 1), G (goto end), w (next word), etc.
So you have all these powerful ways to jump around the file, and you can combine them with all these powerful ways to manipulate the file. And this is just one of the really nice things about vim. The "." (repeat last command) is something I haven't found in any other text editor, and was the main reason I got hooked on vim.
You can also preface those with a quantity. As a pretty arbitrary example,
5dwelp* is "5 delete-word move-to-end-of-next-word right paste", or, "move the next five words forward one word".In Emacs, repeat is C-x z, by the way, and then you can just keep hitting z.
Focusing on what it can do is irrelevant. I've been programming 29 years now. Can't think of a time I've needed to do that.
If I still used vi regularly, I probably could have given you a better example. Actually, I couldn't, but my fingers could have. :) It had all moved to muscle-memory.
Emacs's interface is a bit more cumbersome, but it's also easier to follow it with, "...and from now on, call that X and add it to the interface".
( "some string" )
And I press Ctrl-W, then at first "some" will be selected, then "some string", then ""some string"" (with the quotes).
So assuming that moving my thumb to Ctrl is free, I did it in the same number of key presses as you. Or its 4 vs 3 if you count the ctrl key. Or its 4 vs 4 if you are in insert mode and have to esc first. [Edit: ok, you have to press delete too, so its 5 vs 3 or 5 vs 4.]
The difference, however, is that Ctrl-W is all you have to know. Its just as fast as all your different combinations even for the worst case, but:
a) its often faster - i.e. just two Ctrl-W's for selecting the text inside the string.
b) it provides visual feedback.
Its just as fast for the expert, but yet its obvious, intuitive, and lends itself to discovery based learning. Once you know Ctrl-W selects a word, there's a good chance a user will learn its advanced features by accident, even if they aren't told.
Goto line: Ctrl-G 10.
Goto first line: Ctrl-Home (standard in most GUI editors)
Goto last line: Ctrl-End (also)
The '=' auto indent feature: Ctrl-Alt-L Enter is "format entire file". Its fast, so why would you ever want to format just a little bit? Ctrl-Alt-L Alt-A Enter is format the entire project. I dont have a binding for indent, because why would I ever want to? Just write code, then let editor make it look pretty in one go with Ctrl-Alt-L Enter.
I assume the "." command is used to say repeat a replace or a find: in which case there are keys for that. I'd like to see some use cases for that other than find and replace.
Editors like IntelliJ, SlickEdit, Resharper, all have powerful keybinding support. SlickEdit has a built in scripting language if you want to go crazy. All have far more commands than are actually bound. SlickEdit has a vi mode even.
So you haven't convinced me that vim offers any advantage over a good IDE.
Let's take your example:
("some text")
"cib" will leave you with:
()
no matter where your cursor is (inside the parentheses), and no matter how many words are there. No visual feedback is needed, since you know what the command is going to do. Can your C-w do the same? I don't think so.
This is much ado about nothing, however. Plugins to get Vim-like commands in IDEs do exist. So what? The power of advanced text editors comes from this: they don't do too much, and talk to other tools, and you can compose them in a modular way. Talk about knowledge reuse. IDEs are monoliths, and refuse to talk to outside world... the opposite of modular design. Isn't that ironic? Where is your IDE when you need to edit a blog post? Or when you need to do a big text munging? Your editor will be with you wherever there is text.