5 ms·
One of the best things about vim for me is (for example) the command cib. This deletes everything from your cursor forward to the first "(", and everything afte
by grogers 16y ago
One of the best things about vim for me is (for example) the command cib. This deletes everything from your cursor forward to the first "(", and everything after to the first ")", then places you in insert mode. How do you do that in your editor? I'm guessing you use your mouse to select all this stuff and hit backspace, which is a bunch slower.
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.
- binaryfinery 16y agoCtrl-W is "select word" but it expands each time you press it. So if I'm in the middle of a string, and that string is part of a method call: ( "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.
- lelele 16y agoI'm not convinced by your example, either ;-) 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.
- silentbicycle 16y agoc is probably "change". (Or "convert, I guess.) 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.
- binaryfinery 16y agoa. Use case? b. Shift-Alt-Arrow Shift-Alt-Arrow Shift-Alt-Arrow Shift-Alt-Arrow Shift-Alt-Arrow Ctrl-X Alt-Arrow Alt-V. So 8 vs 5. 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.
- silentbicycle 16y agoA use case for "5dwelp"? Teaching my roommate how vi's interface works, six or seven years ago. It was the first example that popped into my head. (I told you it was arbitrary. I switched to Emacs ~4 years ago.) The real point is that almost the entire vi interface sensibly combines that way, like APL operators. [quantity] [operation] [movement]. 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".
- binaryfinery 16y agoThe real point is that almost the entire vi interface sensibly combines that way to operate on words, lines, paragraphs, regexps etc. Whereas a good IDE works on that which the words, lines, etc represent: i.e. a code dom.
- silentbicycle 16y agoActually, "words, lines, paragraphs" also includes statements, function calls, class definitions, and the rest of the "code dom", in a language-specific manner. Not so in nvi (a barebones vi), but definitely in vim.
- ralph 16y agoc is for change, as d is for delete, i for insert, and s for substitute.