Zmiana nazwy w VSCode

Zmiana nazwy w VSCode
JA
  • Rejestracja: dni
  • Ostatnio: dni
  • Postów: 6
0

Witam, jak zmienić nazwę zmiennej, ale tylko w dolnych wystąpieniach? Próbuję przez to F2 i Ctrl+F2, ale to nie działa.
Dla przykładu chciałbym zmienić nazwę student2 na student3, ale tylko w dolnych wystąpieniach.

Kopiuj
#include <print>
using namespace std;

struct student {
  string name;
  double gpa;
  bool enrolled;
};

int main() {
  // struct
  student student1;
  student1.name = "Spongebob";
  student1.gpa = 3.2;
  student1.enrolled = true;

  println("{}", student1.name);
  println("{}", student1.gpa);
  println("{}", student1.enrolled);

  student student2;
  student2.name = "Patrick";
  student2.gpa = 2.2;
  student2.enrolled = true;

  println("{}", student2.name);
  println("{}", student2.gpa);
  println("{}", student2.enrolled);

  student student2;
  student2.name = "Squidward";
  student2.gpa = 1.2;
  student2.enrolled = true;

  println("{}", student2.name);
  println("{}", student2.gpa);
  println("{}", student2.enrolled);

  return 0;
}

https://stackoverflow.com/questions/47403137/refactor-local-variable-name-using-visual-studio-code

lvyadhjpik
  • Rejestracja: dni
  • Ostatnio: dni
  • Postów: 26
0

Ctrl+D selects the word at the cursor, or the next occurrence of the current selection.

zaznaczasz tekst, robisz CTRL + D aby zaznaczyc kolejne wytapienia. Uwazaj bo mozesz wrocic na poczatek pliku 😉

Zarejestruj się i dołącz do największej społeczności programistów w Polsce.

Otrzymaj wsparcie, dziel się wiedzą i rozwijaj swoje umiejętności z najlepszymi.