Use Vscode command + D only in one function

Viewed 25

My team's code has a javascript file with many functions. The code is like:

function a() {
  newPatinetData.patientEmail = getPatientEmail()
  if(!newPatinetData.patientEmail) {
    throw Error("No email");
  }
  // other code
}

function b() {
  newPatinetData.patientEmail = getPatientEmail()
  if(!newPatinetData.patientEmail) {
    throw Error("No email");
  }
  // other code
}

function c() {
  newPatinetData.patientEmail = getPatientEmail()
  if(!newPatinetData.patientEmail) {
    throw Error("No email");
  }
  // other code
}

Once I want select all "newPatinetData.patientEmail" in function "a" by using "command + D" and rename it to "patientEmail".

Sometimes I will select "newPatinetData.patientEmail" in other function uncarefully.

Is there a way to do it in a smarter way?

0 Answers
Related