Not being a vimmer, can somebody explain to me the big deal about these commands? I mean, selecting and deleting arbitrary blocks of text has never been a problem for me in a modern editor. Delete a line? Home shift+end delete. Slower than the completely-line deletion single-hotkey, but semantically sensible. For by word, that's where ctrl+arrow-keys come in.
I use good old notepad++ for most plain-text work and I never find I'm reaching for the mouse. The normal windows-standard hotkeys are easily memorable and do most of the navigation I need for editing and deleting text.
The only "weird trick" i leverage heavily involving the mouse is VS's column-select.
A regular text editor is low level C. You know what you want to achieve, and so you tell your text editor each step involved in the process and it does exactly what you tell it to.
Vim is a high level language. You know what you want to achieve, and so you express your goal, and the implementation details are irrelevant. Whether you realise you need to change the word you're looking at (ciw - Change In Word), kill off this else branch (da{ - Delete Around Brackets), are annoyed that even though you've all decided to standardise on spaces, somebody just checked in tabs (gg=G - G(g)o to the start of the file, = to reformat according to the configured default, then Go to the end of the file), append to the end of the line (A - Append), or whatever, you can typically express most text editing concepts as some combination of a dozen or two verbs and nouns.
But any reasonably programmer-oriented editor has movement commands to select a bracketed area, go to the beginning of the file, reformat, go to the end (e.g. ctrl-end), go to end of line (end). The only difference between vi and more modern editors is that other editors put the argument before the operator instead of after, and you can always type things. There's no need for an "append" or "insert" command because you are always in editing mode.
No, I think I still disagree with that. Most editors have functionality which can match certain examples, but that's half of what this article is talking about--the emacs school of commands, where you get a large array of monolithic commands, has been well learned.
I've never seen an editor which isn't a vi-derivative have elegant ways to express ideas like "make the rest of this sentence upper case", "wrap this line in single quotes, add a comma at the end, and go down a line. Okay, now do that for every line until the next closing square bracket", or "swap the contents of this string with 'foo bar'", all of which are examples of things I've done in the last week that have saved a decent chunk of time.
Treating vi as a finite list of commands which you can execute is not grokking vi. The composability is what makes it interesting.
Column select to next closing bracket, type the single quote for beginning of line, move column selection to the end of line, and type quote comma.
Select string, ctrl-x, type foo bar. Got anything else?
I haven't used emacs in about two decades, so I can't comment on its supposedly "monolithic" commands, but it sounds like you haven't used anything but vi in almost that long. Any decent programmer's editor's commands operate on fairly arbitrary selections of text -- and the best ones have column selection or other discontinuous selection features, not to mention navigation by nested syntax, etc.
So, the only difference between vi and not-vi is whether the operators go before or after the operands. This is a lisp-vs-forth argument, with vi as lisp (operation selection) and everything else as forth (selection operation). It's just that vi makes people feel more clever about how many keystrokes they can save, but only because they aren't counting the time they spent thinking out what they wanted to do.
But in a non-vi editor, cleverness is unnecessary: I can keep my mind on the code, instead of counting words or lines or keeping track of what mode I'm in.
I use Visual Studio plenty at work, and Sublime Text plenty for non-programming text editing, and I've at least tried most of the other solutions. I don't really see how attacking my experience is beneficial to this kind of debate.
Regardless, your answer to 1 isn't a single command, and so isn't going to compose well in macros or scripts. Your number 2 required you to do a lot of manual selection, as well as manually determining where the closing bracket was, and still doesn't compose into macros well. Your third completely misses the point--I don't mean replacing one string, I mean a command which replaces the contents of a string with some arbitrary text, which you can reuse over and over again.
The idea that vim usage is about saving keystrokes is entirely incorrect, not least because replacing mouse movements with keystrokes typically results in more total keys pressed, not less.
I also don't understand the argument that remembering a set of a dozen or two commands is any more difficult than remembering menus full of specific commands, even if those specific commands covered all the cases. If you're counting lines, or taking any real amount of time to determine how to express what you're trying to do, then you're using your editor inefficiently, which is nothing to be proud of.
The difference between Vim and other editors is hard to explain. Try this:
I want you to type a sentence. The first time you type it, I want you to ball up your fists and point just your index fingers out. Ready, remember, type the sentence exactly as you see it, capitals and punctuation included? Here's your sentence:
Perfection is not attainable, but if we chase perfection we can catch excellence.
Not too bad, but probably not how you normally type. Now, I want you to type the sentence again, this time, type it normally.
How did that feel? That's similar to the feeling that you get when you've internalized the vim way of editing blocks of text. It's not faster or better, but it feels divine in comparison to the hunting and pecking that you used to do with other editing methods.
Sure, but what does that have to do with people who aren't used to it? I'm honestly a bit confused as to why anyone who doesn't already know it would want to learn it at this point.
It's hard to imagine that there's much empirical difference in terms of the speed someone could write, for example, a term paper in vi then in pico or notepad++ or whatever.
So because you have been brainwashed with this editor you believe it is the end all be all?
Give me a break. I work much more efficiently in Atom or Visual Studio than my 50+ year old Vim co-workers. To say Vim is any more efficient because you can't understand a modern editor is both ignorant and retarded.
So because you have been brainwashed with this editor you believe it is the end all be all?
Nope. Vim is a pretty terrible text editor in comparison to many others. It's old and crufty, often slow, and has some absolutely insane defaults that require serious configuration to alleviate.
However, I do love modal editing. Ctrl+C/V/X/A/Y/Z etc. always feel awkward, and don't really interact on words or paragraphs or blocks of code. Text objects are powerful, and the modal editing lets bindings for common text-editing actions be set on the keyboard in less awkward ways (except ctrl+a and ctrl+y, wtf vim, you're drunk). Sublime text has some of the text objects, like emacs long before it, but it's missing the modal editing piece which I feel is vim's superpower.
Fortunately for me, there's a vim-mode for damn near everything, including emacs. I don't use the Vim (gVim) application much anymore (it's replaced Notepad and Notepad++, but that's it). I use an IDE, and most IDEs have vim-mode plugins.
And delete 2 or 3 lines? In vim you'd just prepend the number of times you want to do something. So if deleting a line is dd, then deleting 3 lines is 3dd.
You can do everything Vim can using plain commands, but Vim does it more efficiently and allows you to chain the commands together automatically.
For the common case it's much faster to type daw or diw to delete the word the cursor is already on than it is to move to the beginning of the word, mark it with ctrl+arrow, then delete. In the end you've done the same thing, sure, but it was much quicker with Vim. Reusing the same mnemonic key is also a big help. Once you know that the text object iw refers to the word you're on sans whitespace you can combine it with any editing command: delete, copy/yank, replace, upper/lower case, reformat.
it's much faster to type daw or diw to delete the word the cursor is already on than it is to move to the beginning of the word, mark it with ctrl+arrow, then delete
But I wouldn't do that. I'd use ctrl-left to go to the start of the word, then ctrl-delete to delete the word. And I wouldn't have to do any mode changes to achieve that.
I'm not saying that this is better or worse than Vim. Actually, I'd say that it's a similar amount of work. I think Vim really starts to shine with more complex examples.
38
u/[deleted] May 08 '16
Not being a vimmer, can somebody explain to me the big deal about these commands? I mean, selecting and deleting arbitrary blocks of text has never been a problem for me in a modern editor. Delete a line? Home shift+end delete. Slower than the completely-line deletion single-hotkey, but semantically sensible. For by word, that's where ctrl+arrow-keys come in.
I use good old notepad++ for most plain-text work and I never find I'm reaching for the mouse. The normal windows-standard hotkeys are easily memorable and do most of the navigation I need for editing and deleting text.
The only "weird trick" i leverage heavily involving the mouse is VS's column-select.