Today, for the first time since I've started coding, I had a legitimate use case for the multi-cursor feature of my IDE in reasonably DRY code.

Edit: nvm, I added a version of the function to support arrays on the first argument.

  • 8
    You never use it?
    What about quickly constructing an array from pasted data? Cleaning up styling around hashes/dicts? Quick vertical alignment? Renaming vars/methods? Converting between single/double quotes or back ticks? Quickly constructing similar-but-different lines from a set of vars?

    I use it more than any other editor feature except autocomplete.
  • 1
    @Root you can instead use find and replace in probably all cases
  • 3
    @electrineer I could write a find/replace regex for them, sure, and apply it to a selection. But it’s significantly faster and easier to use multi-caret. Often fewer keystrokes, too.
  • 3
    Multi cursor is an amazing invention.
  • 0
    Here's what I do in the situations you mentioned:
    I rarely paste data, and when I do, I transform it in an empty buffer using find&replace.
    I don't understand what it could be used for in hashes
    For vertical alignment there's select[+shift]+tab
    For renaming a symbol the only failsafe method is the IDE's own. find&replace will give false positives, manually selecting will miss some.
    Converting between delimiters is also a job for find&replace, or preferably a linter so I don't accidentally overwrite within literals.
    And I don't have the kind of foresight to realise that the next line would be similar. Rather, I just copy and modify, which is somewhat slower but works afterwards.
Add Comment