4 ms·
Vim doesn't need multiple cursor support. Train yourself to think in Vim—you're editing text and words, not moving a cursor. Macros and global replace already
by beaumartinez 12y ago
Vim doesn't need multiple cursor support. Train yourself to think in Vim—you're editing text and words, not moving a cursor.
Macros and global replace already do what you want.
- edanm 12y agoMacros and global replace are substitutes, sure, but they're not at all the same thing. And while I'm no vim wizard, I have used it as my main editor for 4+ years, and have a 1500 line vimrc and plenty of plugins (including my own), so you don't get to assume I don't grok the vim way of thinking :) I've heard the "macros is the same" sentiment many times, and usually it's from people who have never had much experience with multiple cursors, at least not in the situations where it's useful, and therefore don't realize how much more convenient they are in many every-day situations. In fact, many of the people arguing against multi-cursors have been convinced after trying them that they are better. Please, read my linked comment for an all-too-common situation. The basic problem with macros and global replace is that they don't happen immediately and don't give you feedback. I don't know any vim user who hasn't had the distinct pleasure of needing 3 tries to record a macro before they got it right. What's more, if I record a macro and run it, then realize after it that I want to do a small addition, I have to go through all the "setup" steps again - go back to the start, re-record, add the logical of finding the next block, and so on. I can't just visually see the situation and say "oh yeah, why don't I add this little tweak". Seriously, take a very common example: having 3 if's one after the other, where you want to add a line at the start of each if block. Doing this with multiple cursors is a breeze - 3 buttons and you get 3 cursors, then write your code. And if, after writing it, you realize you actually want to add another line, you just keep typing. It's literally the same as typing. Anyway, I've rambled enough on this topic many times. Please, just give them a try - I care a lot about text editors, I love this field, and I honestly think multiple cursors is the best innovation to happen in text editing in many years. And yet it's so often overlooked.
- Morgawr 12y ago>In fact, many of the people arguing against multi-cursors have been convinced after trying them that they are better. Fact by who? >The basic problem with macros and global replace is that they don't happen immediately and don't give you feedback. I don't know any vim user who hasn't had the distinct pleasure of needing 3 tries to record a macro before they got it right. True about macros, which are a very powerful tool that's way more than just multiple cursors. For global replace, however, this is false. Vim has an option to enable visual feedback for select/replace commands. I use it every day and it's awesome. >What's more, if I record a macro and run it, then realize after it that I want to do a small addition, I have to go through all the "setup" steps again - go back to the start, re-record, add the logical of finding the next block, and so on. I can't just visually see the situation and say "oh yeah, why don't I add this little tweak". What about recording the rest of the macro and running both of them one after the other? >Seriously, take a very common example: having 3 if's one after the other, where you want to add a line at the start of each if block. Doing this with multiple cursors is a breeze - 3 buttons and you get 3 cursors, then write your code. And if, after writing it, you realize you actually want to add another line, you just keep typing. It's literally the same as typing. v<linenum>j:s/if/<whatever>if/g oh wait, I wanted to add another line? uv<linenum>j:<up><change regex> Also as somebody already pointed out, vim already has plugin(s) for multiple cursor support and they work exactly as they should. I'm not arguing against multiple cursors, I'm just saying that they don't really bring anything new.
- bilalq 12y agoJust to add to that, you can also use visual block mode to change text on multiple lines. You get a lot of the benefits of multiple cursors that way while still doing things in a more traditional "vim-like" way.
- edanm 12y agoNo reason not to do things in a vim-like way with multiple cursors. In fact, they're literally just an extension of the block-mode concept, except that it's just better because it allows you to do a superset of things.
- 12y ago
- gkya 12y ago> [I] have a 1500 line vimrc and plenty of plugins (including my own), so you don't get to assume I don't grok the vim way of thinking :) This may only show that you grok VimScript way of thinking, not Vim way of thinking. You need not re-record a macro, a macro is stored in a register. Just edit the register, and you're good to go with you new, (supposedly) improved macro. In Vim, you edit in Normal mode, and insert in insert mode. Multiple cursors is a means of moving editing into insert mode, and thus in spite of the Vim way. I am an Emacs user * and there is a multiple-cursors mode for Emacs, which quite useful as Emacs is modeless. * If we're doing SLOC porn here, I've a ~400 SLOC vimrc with nice gems in it, and is nicely and extensively commented. I've switched to Emacs for my love of Lisp and newfangled dislike of some parts of Unix.
- bdamm 12y agoMy .vimrc used to be large, but now has dwindled down to a handful of simple commands. I've simply adapted to be maximally productive in a nearly pure vim environment. Does this make me less of a vim user?
- gkya 12y agoIt rather makes you more of a vim user. My vimrc file contains mostly leader mappings and option settings, added mostly with a craze of customising.
- edanm 12y ago"This may only show that you grok VimScript way of thinking, not Vim way of thinking." True enough that it doesn't prove anything. "You need not re-record a macro, a macro is stored in a register. Just edit the register, and you're good to go with you new, (supposedly) improved macro." I know. And if you think this process is easier, faster, or saves keystrokes over using multiple cursors, then I think you're wrong. "In Vim, you edit in Normal mode, and insert in insert mode. Multiple cursors is a means of moving editing into insert mode, and thus in spite of the Vim way." No no no! That's the beauty of using multiple cursors in vim. You can have (potentially) multiple cursors in Normal Mode, and use all the normal vim commands. That's what makes it so sad that it doesn't have multiple cursors, because if you can merge the power of multiple cursors with the power of vim, you get something amazing. Imagine having the following: <pre> <div>some text</div> <div>Some other text</div> <div>Third</div> </pre> Then imagine you want to, for some reason, copy-paste the contents of the different divs into (say) another buffer. With multiple cursors, you can select the three lines, use the vim commands to yank the text object that's in between the divs (yit), and then paste it elsewhere. This is not possible in Sublime Text, since it has no way of saying "select text between divs". Or even, doesn't have vim's "f" command so one could jump to the "<" character opening the second div.
- q_revert 12y ago> What's more, if I record a macro and run it, then realize after it that I want to do a small addition, I have to go through all the "setup" steps again - go back to the start, re-record, add the logical of finding the next block, and so on. I can't just visually see the situation and say "oh yeah, why don't I add this little tweak". this is very doable, lets say you record a macro to 'a' 1. q: 2. let @a=' 3. ^r^ra to put in the current contents of the macro 4. edit as you see fit --- you should now have something like --- let @a='contents of macro' 5. ??? 6. profit