6 ms·
I wrote a custom mod more than 15 years ago for SciTE that exposed its plugin API to Ruby and wrote some of my own plugins. It didn't support multiple cursors a
by speps 3y ago
I wrote a custom mod more than 15 years ago for SciTE that exposed its plugin API to Ruby and wrote some of my own plugins. It didn't support multiple cursors and I instantly switched to Sublime as soon as I discovered that feature, never looked back.
- jmole 3y agoWhat are multiple cursors used for?
- jdc0589 3y agobeen a while since I used it, but it was handy for templates where you need to enter a name once and have it typed in multiple places in the template (quicker than a find/replace). It was a also handy sometimes to just be able to put your cursor on the name of a variable or bigger text selection, smash cmd+d a handful of times to add another cursor at every other occurrences of it in the file, and then just start typing to modify each of those occurrences.
- input_sh 3y agoIf you're using the same variable name across the file, but want to change only a couple of references to something else, it fills that "I need to do this more than once, but in a bit of an easier to reach, fancier way than with find and replace" niche.
- AeroNotix 3y agoMost editors these days should have "rename" functionality which is very aware of how that symbol is used across a codebase. M-x lsp-rename in emacs, for example works great, if you're using lsp.
- rezonant 3y agoYes but this is more general, allowing you to use it in more cases. For instance, I use it heavily when converting old JavaScript to modern ES/TS. Using "var" everywhere? Replace them all with let. Using anonymous functions instead of lambdas, easy to change those all over (provided there's no "this" dependencies) Have two thousand strings which all need the same edits? No need to do a find/replace operation, you can do it directly in the editor.
- layer8 3y agoHow do you select those two thousand strings?
- zimmund 3y agoUsing VS Code: select whatever you want to match, then Ctrl+Shift+L
- layer8 3y agoSo it has to be two thousand identical strings? Then I don’t understand the benefit over search & replace.
- rezonant 3y agoIt goes further than just that -- for instance, lets say your data looks like this: [ "foo bar/2322", "foo baz/4223", "foo blah/2232", ... ] And you need to reformat that into: [ "bar 2322: foo", "baz 4223: foo", "blah 2232: foo", ... ] You can absolutely use a regular expression find/replace to solve this. But using multicursors, you can just highlight the first "foo ", then hold Ctrl+D to select all instances, then hit right arrow key so that your cursors are at "foo |bar/2322" (and nothing is selected) et al, then use shift+right arrow key to select bar, baz, blah, and all other substrings, then use ctrl+X to cut that list to your clipboard. Hit delete key to get rid of the /s and add a space so you can keep the fields separated. Then, use ctrl+arrow to move your cursors to just before foo ("|foo /2322"), paste, hit space. Now you have "bar foo 2322". Repeat the same action to cut all the "foo" substrings, then move your cursor to the end, now type ": " and then paste. You get the idea. It sounds complex, but these are all just comprised of the same fundamental editing patterns-- all of the cursors act as if you had just that one cursor when you press the keys. You have to play with multicursors to really appreciate their power. Most of the time, someone who is well versed with multicursors and their editor's cursor shortcuts (arrow keys, page up/down, shift/ctrl arrow keys, etc) will be able to complete these sort of textual manipulations much faster than using find/replace.
- neoromantique 3y agoIt helps when it is a bit more interactive, i.e when I only need to replace some of the occurrences versus everything. Also when working with lists it is useful, you spawn cursors on , or < or whatever symbol you've got at a fixed location between lines, and then you can manipulate text in any number of otherwise different lines.
- twodave 3y agoI use it to: * transform a list of field names into different formats (class properties, sql select list, etc.) * quick and dirty convert delimited text into insert statements or graphql queries or json objects * really anything I need to change in column mode but with better tracking of words via mod+arrow keys
- blacksmith_tb 3y agoI use it all the time to mangle small amounts of data, like selecting all the newlines in a file with cntrl-d and making them into "," to make it into values for an array or something (obv. search+replace could do that, still it's quicker for a small number this way, or feels like it). It was pretty slick in the early TextMate / Sublime days to see people editing html and making a big bunch of tags all write themselves out simultaneously.
- nolongerthere 3y agoI use it daily in vscode to clean up small data sets where wrangling regex will take more time, and the data set isn’t something that I’m gonna see again so it’s not worth generalizing a solution.
- rezonant 3y agoAny time you need to make the same edits in multiple places. I use it to mass edit array items for example by using the highlight / add cursor to identical text feature in VS Code (Ctrl+D). I even use it to copy data out of the browser and mass edit it into data structures-- often there will be some pattern to the pasted data even if it's garbage, so being able to quickly set up multicursors around the patterns in the text makes this sort of task much easier, if you are luckily on how the data pastes out. Multicursors are the number one editor innovation of the last ten years that developers should get comfortable with-- once you start to use them you won't want to use an editor without them.
- innocenat 3y agoPersonally while there are some task that's easier with multiple cursors, I have personally yet to find any use case where regexp replace in selections doesn't work as well.
- germandiago 3y agoI find Emacs Macros and rectangular editing as more useful in lore situations than multiple cursors. As for regexps, the syntax in Emacs is hell, but I do know Emcacs has very powerful edit/replace tools.
- cylinder714 3y ago"Emcacs"...I like it.
- germandiago 3y agoYeah... typing fast and from the phone has this problem
- overtomanu 3y agoMulti-cursor is more flexible than rectangular selection. You can skip or delete words of varying length etc. It is certainly less powerful than vim macro and regex, but it's easy to use because 1) there are less shortcuts to remember 2) no need to think too much like figuring out regex for simple tasks 3) it gives instant feedback Video showing this https://youtu.be/lhFNWTAIzOI?t=28 https://youtu.be/lhFNWTAIzOI?t=28