I tried out vim for a month or so. I did enjoy using it, although I'm not sure if using vim just feels more productive because you press more keys to do the same thing.
However multi-cursor editing and cutting whole lines in modern editors is way more conducive to my workflow and eventually stopped using vim.
Do vim users know if there was anything like Select next occurrence in vim? Feature discovery is not one of vims strong suites
EDIT: More specifically by multi-cursor editing I mean selecting multiple occurrences of a word, and then editing in place. For example selecting all occurrences of the word user -> (getUser, setUserId, variable declarations with user) and then replacing them with account. This can be done with vim but is nowhere near as fast, since every change needs to be done one-by-one.
Or selecting all the above occurrences, and pasting them somewhere for an interface declaration.
I use / to search by a string (or press * while my cursor is on a word to search for that word), then press n or p to go to the next or previous. cgn changes the matched text, and you use . to repeat the change, so to change a word over all occurrences I just cgn once and repeatedly press “.” .
> selecting multiple occurrences of a word, and then editing in place
I'm sure there is a way to do this More Properly, but the kind of thing I'd do is:
:%s/user/account/g
:%s/User/Account/g
If you wanted to check each one interactively, end with gc instead of g.
Vim is the reason I'm real confident with regexes, even nonsense with grouping and quantifiers etc. etc., and while I can see people not wanting to have to acquire that power, I must say it's also very handy outside of text editing.
> selecting all the above occurrences, and pasting them somewhere for an interface declaration.
I don't really understand the behavior desired here, but I'll bet there's something similar.
If I'm interpreting "cutting whole lines" correctly, in vim that's "dd" in normal mode. Then you can paste (put) with "p".
I agree discoverability is not great; to be honest I can't remember how I discovered the plethora of commands I use, though I do have a habit of reading the help a decent amount. That's how I discovered "g?" (Rot13) :D
> they don't allow selecting multiple lines that don't follow each other.
3dd won't work. You can use registers, though:
1. "ayy for the first line
2. "Ayy for the subsequent lines (repeat using .)
3. "ap to paste.
You can replace a/A with other letters to copy into multiple registers. If there are patterns (e.g. odd lines to A and even lines to B), you can even record a macro.
I think registers are not something most Vim users use, however. I have no data to back this up, but I wouldn't be surprised if Vim is like Git, where people learn the commands for 80% of scenarios and Google the rest. In Vim, case, they might even settle for a very inefficient solution if the problem is not recurring.
I am aware that I could extend vim with all the missing features, but that seems error-prone and not worth the time investment, since other editors have them out-of-the-box.
Nowadays I have almost the opposite feeling of it not being worth my time and being error-prone to take up with some editor gui when my terminal already gives me an editor that does everything I want from it and in exactly the way I want it.
But I remember having your stand point when I first started to try to get into vim and getting to where I am now definitely took a lot of invested time. Wether the advantages of vim are worth your time you have to decide for yourself and it seems like you did that already.
> Do vim users know if there was anything like Select next occurrence in vim?
As noted in a sibling, you can press * (shift+8) in normal mode with your cursor over a word to find the next instance of the word. This also updates the search pattern so you can use n and shift+n to navigate forward and back between matches.
If you combine this with other bits of the vim "grammar" (which I do think encourages a kind of feature discovery, although I agree there's a large learning "hump" to get over to take advantage of it), you can use something like cgn to change the currently-focused search match, n to navigate to the next search match, and . to replay the command.
So while it's not exactly the same as multi-cursor, you can achieve something very similar (and just as fast) with the following sequence:
1. In normal mode, place the cursor over the symbol you wish to edit
2. Press key: \* (read: "find the next occurrence of the current symbol and update the search pattern to be that string")
3. Press keys: cgn (read: "change the search match under the cursor")
4. Type the new symbol
5. Press ESC to return to normal mode
6. Press keys: n. (read "find the next occurrence of the search pattern [set in step 2] and repeat the last command [the edit from steps 3-5]")
7. Repeat 6 until all symbols are replaced
Or, in raw keystrokes, I might replace all six "foo"s in a document with "bar" by typing the following sequence of characters (having placed the cursor over a "foo"): *cgnbar<ESC>n.n.n.n.n.
It may seem complex compared to something like multi-cursor editing, but the nice thing here is that there are concepts here that are extensible beyond the scope of that specific edit, and can yield similar "speedy" workflows but on a much wider set of tasks.
- c[something] is a pattern that means "change [the given region]", so you could construct similar commands with different regions (`ciw` to change inside the current word, `ca{` to change the current curly-bracketed region (inclusive), and so on)
- [something]gn is a pattern that means "[do something] to the next search match", so you could delete it with `dgn`.
- . can replay many types of commands, so if I have a more complex sequence of edits to apply starting at a search match, I could do that too (not just simply replacing the symbol).
Yep. I use the VIM extension for Vs Code. I do a CMD-SHIFT-P -> Disable Vim whenever I need this functionality. Not sure if there's a better way to do it.
Do vim users know if there was anything like Select next occurrence in vim? Feature discovery is not one of vims strong suites
EDIT: More specifically by multi-cursor editing I mean selecting multiple occurrences of a word, and then editing in place. For example selecting all occurrences of the word user -> (getUser, setUserId, variable declarations with user) and then replacing them with account. This can be done with vim but is nowhere near as fast, since every change needs to be done one-by-one. Or selecting all the above occurrences, and pasting them somewhere for an interface declaration.