4 ms·
Multiple cursors sound cool! In vim, you can do something more limited by using visual block mode (C-v) to insert on multiple lines, but you're restricted to i
by groovy2shoes 14y ago
Multiple cursors sound cool! In vim, you can do something more limited by using visual block mode (C-v) to insert on multiple lines, but you're restricted to insertion on the same column.
The perhaps the closest thing I can think of for your example would be this (starting in normal mode with the cursor at the beginning of your list):
f_i_Class<Esc>+;.+;.
("Move forward to the next '_', enter insert mode, insert '_Class', leave insert mode, move down one line to the first non-blank character, repeat the forward motion, repeat the insertion, repeat forward motion, repeat insertion." Vim does have word motions, but it includes underscores as parts of words.)
Edit - formatting and a clarification that it's the closest I can think of (I'm doubtful it's the closest you can get).
- notJim 14y agoYeah, I'd record that as a macro and replay it line by line I think.
- LiveTheDream 14y agoMacros are the way I solve this as well. A little practice, and you won't even notice the difference. Just hit `Esc j` before ending the macro recording and moving down a line is no longer a problem :)
- irahul 14y agoRather than replaying it line by line, you can play it over a range. If you do this in your vimrc: vnoremap @q :normal @q<CR> You can record the macro in q register, select the visual range, and then do @q to run it over the range. The advantage of doing it thus is you don't have to run the macro manually on every line, and you can undo all change with one u. Also, normal takes ranges(and not just visual ranges). If you want to run the macro recorded in q over lines 15,49, you can do: :15,49normal @q<CR> I use the same trick for repeating commands over a range too. vnoremap . normal .<CR> As usual, it doesn't have to be visual range. But I mostly use visual ranges, and so I have defined shortcuts for visual ranges.
- clscott 14y agoYou wouldn't do the following? :% s/_/_Class_/ Explained: On each line replace the first '_' with '_Class_'
- notJim 14y agoYeah, that's totally what you'd do, in either editor. But my broader point is that there are situations where the immediate feedback and interactivity of using multiple cursors is valuable.
- johncoltrane 14y agoI've tried to like it and believe that instant feedback is actually useful but no. I couldn't.
- jasonm23 14y agoEmacs IEdit mode has done this for years
- irahul 14y agoHow is immediate feedback and interactivity going to help if the changes span more than one page? If you are going to extrapolate(looks fine on this page, must be fine elsewhere), you can very well extrapolate from a smaller sample size(run :s/some_crap/some_other_crap/gc, check one or two occurrences, then do 'a' for all).
- imatworkyo 14y agoOne can always stop typing and simply scroll down and check.