9 ms·
> multiple cursors But seriously though, why does everything these days need multiple cursors? It's a confusing visual gimmick in every scenario I've seen it i
by Arch-TK 2y ago
> multiple cursors
But seriously though, why does everything these days need multiple cursors? It's a confusing visual gimmick in every scenario I've seen it implemented in. I'll take fully fleshed out structural regular expressions or even perl-re over multiple cursors any day. Combined with as vim's [c]onfirm flag you get all the benefits of multiple cursors without all the clunky downsides and weirdness.
- wodenokoto 2y agoWhen I need to edit the code around next five instance of "foo", but not every instance in the open file, then I don't know how to do that with structural regular expression, but pressing ctr+d five times and then edit what I want is really straight forward. And I need to edit around a limited version of foo way more often than I need to edit all instances.
- globular-toast 2y agoYou would restrict your regexp to a region. In Emacs you just select a region somehow (like your press ctrl+d five times), then just do the regexp replace.
- vulcan01 2y agoNotice that you also don't need to write a regex with multiple cursors - instead, you can visually see your selections and changes as you go, using the same editing motions that you would typically use.
- msravi 2y agoIn vim, to replace in the next 5 lines (not instances) :.,.+5s/findtext/replacetext/g In neovim, you'll see a preview of the changes as you type the regexp. Neovim is really good.
- buster 2y agoIt's mostly a matter of taste. I do use multiple cursors quite often in Sublime Text when needing to edit some CSV or JSON file. It's probably the feature of Sublime Text, why i'm still having the editor around. It work's extremely well. I could type ":.,.+5s/findtext/replacetext/g" in vim (and remember the syntax!) or i just could do "ctrl-d, ctrl-d, ctrl-d, ctrl-d, ctrl-d, replacetext" and have a visual, immediate confirmation on what i am doing. But i bet you, that i'll press ctrl-d 5 times faster than you entering ":.,.+5s/".
- deleted 2y ago[deleted]
- samatman 2y agoI more commonly solve a problem like this one with /findtext<CR>creplacetext<Esc>n.n.n.n. Remembering the syntax is not a problem here. Learning it in the first place, on the other hand... I do like multiple cursors though. I end up switching to VSCode a couple times a week to do things where it's the right tool for the job.
- iudqnolq 2y agoWhat about holding down the shift arrow, pressing the down arrow five times, then ctrl-r? In most IDEs replace with an active selection will default to replacing only in the selection.
- johnisgood 2y agoYou do not have to remember the syntax; you can use Vimscript and you can create a custom keybinding that prompts you for the "findtext" and "replacetext" strings, then apply the search-and-replace operation over the next 5 lines (number of lines is easily adjustable and can be prompted for it, too; it does not have to be hard-coded either). Vim users don't have to choose between precision and ease of use as you can build macros or mappings that match ANY workflow, creating powerful, customized processes that minimize the need to remember exact syntax or type it all out, for example achieving results similar to multiple cursors but with Vim's inherent efficiency and scalability. So, while Sublime Text's multiple cursors are handy, Vim can match - and even exceed - this functionality with very little setup (emphasis: one time setup!). (I use VSCodium (which I really enjoy) for Go, PHP, and Elixir; IntelliJ IDEA for Java and Kotlin, and I use both Emacs and Vim for everything else).
- specialist 2y agoI'd watch this twitch stream. Contemporary editors are like 5-axis CNC mills and I'm still banging the rocks together. My occasional use multiple cursors is very basic. Your strategy wouldn't even occur to me. Ages ago, Suresh Bhavanani (sp?) studied (suboptimum) usage of office and CADD applications. He was hired by the Army Corps of Engineers to help determine why adoption of CADD hadn't resulted in either higher productivity or improved quality. His theory, which I believe, is various people have various "strategies" of varying merit. But for some reason users didn't (couldn't) readily learn better techniques from each other. IIRC, His two proposals were 1) re-organize user interfaces around tasks, instead of a features and 2) update training materials emphasize strategies. IIRC, he compared manual and digital drafting. He identified a bunch of implicit and explicit "strategies" for manual work. eg Using ink and mylar, skilled drafters would work right-to-left, to avoid smudging prior work. Many early adopters carried those manual strategies over to CADD. Suboptimal, right? So then Suresh identified a bunch of digital appropriate strategies, leveraging the new tool. Suresh did the same for spreadsheets. Any way, this is a too long ramble now ending with the point: It'd be nice to see how others organize their work. I'm sure there's a lot of low hanging fruit "strategies". All the day to day tricks that experts use that don't get captured and explained in our training materials.
- globular-toast 2y agoI see multiple cursors as an alternative to macros rather than regexp. There's stuff that is really awkward with regexp, like anything involving multiple lines, for example. But more importantly, macros and multiple cursors have the opportunity to operate at a higher-level, ie. taking into account language syntax and editor modes etc. Regexp is just about text. Having said that when I see people using it they are just doing a glorified regexp replace more often than not.
- subjectsigma 2y agoI feel exactly the opposite, macros and regexps always felt like I was trying to shoot something blindfolded, it was always awkward and usually didn’t work the first time. Multiple cursors provide immediate visual feedback. Once I started using them they replaced macros and find-and-replace immediately. I don’t use an editor unless it supports multiple cursors. What “clunky downsides and weirdness” are you experiencing?
- frou_dh 2y agoWhy don't you use regex for all editing in the single-cursor case as well then?
- msravi 2y agoIf I want to change a word on one line, I find it faster to do <esc>cw replacetext rather than use the mouse to select the text and then replace text. If I want to do that on 2-3 lines, I just use /findtext n and . to redo the prev command. Anything more than that becomes a full search/replace. Ymmv. It's just what I find efficient, given my muscle memory.
- frou_dh 2y agoThe point is that single-cursor editing is a special case of multiple-cursor editing. If there's value in any single-cursor editing operations that don't use regex (or other indirectness) then they have value when used with multiple cursors, too. The mouse doesn't necessarily come into the discussion at all.
- nextcaller 2y agoI find multiple cursors very useful, a must-have. However I think there needs to be more "safety" around them. It's very easy to accidentally have multiple cursors active without you knowing, and the next thing you type changed something you didn't intend to. I would appreciate if there was some sort of lock I can apply to multiple cursors, to only use them when I need them and when I'm aware that I'm using them.
- aragonite 2y ago> However I think there needs to be more "safety" around them. It's very easy to accidentally have multiple cursors active without you knowing ... Relatedly, if you've created cursors across many lines (or more lines than fit in your viewport), and for whatever reason you want to move all the cursors to the start or end of lines, you want to press Home/End not once, but twice, due to to possible word wrapping on lines outside your view. I've lost nontrivial work by making this mistake!
- sevensor 2y agoVim is a great editor, and when I see people laboriously clicking to create multiple cursors to do something that a simple s/foo/bar/g would accomplish, I feel sorry for them. However, multiple cursors can be pretty great; I love the implementation in kakoune, where I can make multiple selections and then replace them with the output of piping them through an arbitrary shell command. I like to do this with basic math I write out as inputs to dc and then transform to the computed results using select and pipe.
- spartanatreyu 2y agoWould s/foo/bar/g change every foo into bar without also changing every food into bard? Also in most use cases, clicking for each multicursor is the wrong way to do it. With multicursor you can: - Press a shortcut to auto select every instance of the characters that you already have highlighted (which is just s/foo/bar/g with visual feedback before confirming) - Press your "select next occurrence" shortcut a few times so you're only changing the first few occurrences that you care about. - Press your "select next occurrence" shortcut to select the instances you want and press your "skip next occurrence" shortcut to skip the instances you want to keep. That way you can change a bunch of "foo"s to "bar"s while keeping all "food"s as "food"s but also keeping those few instances of "foo" that you want to stay as "foo" (such as in comments, imports, tests, etc...) - Press your "select next occurrence" shortcut (usually ctrl/cmd + d) each time if you literally want to see each instance before moving on to the next. Usually this is when you really want to make sure of something next to one of the occurrences. - And finally clicking each cursor if there really is no simple pre-existing pattern for where you're trying to make changes
- PyWoody 2y agoIn vim, you can do s/foo/bar/gc to iteratively confirm or skip each replacement.
- sevensor 2y ago> Would s/foo/bar/g change every foo into bar without also changing every food into bard? Sure, and if that’s the case you write a better pattern. The replacement s/foo/bar/g applies only to the current line as written. It’s easy to see if it will work or not. But if you also have food on the same line, you can write s/foo\ze\W/bar/g to match foo followed by a non-letter and replace only foo. > Also in most use cases, clicking for each multicursor is the wrong way to do it. Maybe, but I’ve sure spent a lot of time pair programming with people who do it, which is why I bring it up. For what it’s worth, I prefer multicursors, and my find-and-replace workflow is much as you describe, albeit entirely keyboard and regex driven. Your average junior programmer who just learned vscode three or four years ago only knows multiclicking though, and I don’t want to kill the momentum by interrupting to point out how they could use their tools better.
- freetonik 2y agoI cannot imagine a workflow without multiple cursors. I use this feature dozens of times every single day. It became a subconscious part of how I edit text.
- t-3 2y agoMultiple cursors aren't really any different from regex for editing, but are much easier for the layman to pick up and often much quicker for edits where the regex would be complicated and verbose. If my edit-scope is within a single screen or so, I will almost never use regex before multiple cursors. They are incredibly useful for writing new content though (just think about all the times text or code is structurally repetitive with lots of identical boilerplate).
- gpderetta 2y agoSome people can craft the perfect command ahead of time to execute an series of editing operations on the first try. Some other people (/raises hand) prefer to visual incremental feedback on an in-progress operation and be able to partially undo mistakes as they go.
- skydhash 2y agoWith Vim it’s all local decision unless writing a macro or regex substitution would take less time (the structure is very repetitive). Often it’s just n.n.n.n. (Next search occurence and repeat last edit)
- reportgunner 2y agoPeople coming from word or notepad have no idea what 'n.n.n.n.' is supposed to be - they know how a cursor works though.
- rk06 2y agoTwo rules of success: 1. Be attractive 2. Don't be unattractive Lack of multi cursor supprot is unattractive in current era.
- sexyman48 2y agoTom Brady agrees.
- quadsteel 2y agoWay less mental overhead than macros and much faster for most cases. You might wanna look at them beyond surface level, they\'re actually awesome. Having both is even better. While I'm not a fan of Helix's selection→action model it's a great example of how macros&multicursors go very well together. Soon to be on neovim native too, so there's that
- Vegenoid 2y agoI use multiple cursors all the time in Kakoune. Say I want to make a change that is very similar on 10 adjacent lines. I could write a regex or macro that does what I want, which will require me doing that with no visual feedback as I build it. Instead, I can put a cursor on each line and see if I’m getting it right as I’m making the changes. To me, it is an easier, more interactive way of doing the things you’d usually do with a macro in Vim.
- robenkleene 2y agoMultiple cursors are just live visual feedback for editing macros. Generally live visual feedback is a universal good, e.g., I'd argue most innovations in desktop user interfaces for creative apps are using Moore's Law to take modal interfaces and make them live (and correspondingly, non-destructive). E.g., find-as-you-type search and fuzzy finders being a couple examples, as well as most changes to Photoshop, GPU-based rendering IPR views, the entire existence of Lightroom and Ableton Live as apps. With that said, the reason live visual feedback haven't systemically replaced all previous modal interfaces, the way they have for media editing apps, is because it's easier to picture the result of a text editor (i.e., relative to a HSR change to a photo), so it's not quite as revolutionary for text editing as it is applied elsewhere, I'd still argue it's a universal good though, more visual feedback is always better.
- dxuh 2y agoI use multiple cursors multiple times per hour when programming. I do not like vim and I don't use regex. And I am convinced I am faster this way than I could ever be using vim or regex for common editing operations. They are ubiquitous but imho still underrated.