0

In VSCode, I'd like to be able to transform multiple search hits into multiple cursor locations.

In VSCode, I'd like to find all instance of a term (e.g., "fred") and insert a cursor at each location where the term appears. Here, the particular interest is using alt-arrow to reposition the lines in the code. I'm aware that I can alt-shift-I to turn a selection into multiple line cursors but I haven't gotten this too work with the search/replace box. (I could also write a regex expression to do this, but it would be more straightforward with a multiple cursor.)

In the sample below, the pipe | character represents an insertion point. What I want to do is use the find command to locate all the instances of "fred" and then have a cursor appear at the fred locations. E.g.,

var first = {
  name: fred|,
  location: NJ
};
var second = {
  name: fred|,
  location: CT
};
var thrid = {
  name: jane,
  location: OH
}
var fourth = {
  name: fred|,
  location: WY
}
Charles Goodwin
  • 584
  • 5
  • 8
  • You can always do find and replace all using `ctrl + shift + f` – sanketd617 Aug 22 '19 at 16:17
  • I know how to do this manually, but depending on file size it can be a pain. Select keyword and then Ctrl / Command + D. You'll advance through every appearance of the keyword and get a cursor set at its end. – Alex D Aug 22 '19 at 16:20
  • @sanketd617, Alex D., thanks, but these techniques require moving each line individually, which is tedious when you're dealing with 160 lines that need to be relocated... – Charles Goodwin Aug 22 '19 at 16:22
  • @sanketd617 -- that technique doesn't work with ctrl-f searches. I wouldn't be surprised if there is no way to do this, so I get to write some gnarly regex. – Charles Goodwin Aug 22 '19 at 16:46

0 Answers0