Cannot Bulk Rename php in VSCODE Edit

Asked 1 years ago, Updated 1 years ago, 265 views

I use VSCODE to write the php code.
I'm going to rename a variable or function.

Many sites say "Press F2", but
When I actually press F2, there is no response.

The variable has a cursor and the variable is selected, all of which are unresponsive.

Click Ctrl-F2 to change the string.
It is not available because it ignores the scope and changes all characters.

function sample1(){
  $result=1;//<=Change this
  return$resutl;
}
function sample2(){
  $ResultSample=2;
  return$ResultSample;
}

/// If resetl is hoho, the following occurs:
function sample1(){
  $hogehoge=1;
  return $hogehoge;
}
function sample2(){
  $hogehogeSample=2;
  return $hogehogeSample;
}

By the way, when editing vue, you can change the name of the in-scope variable with the "f2 key when the variable has a cursor (not selected)."

There seems to be some configuration, but I couldn't find it in the search engine.
Is there anything that needs to be expanded?
Thank you for your cooperation.

php vscode

2023-02-12 16:13

1 Answers

In VS Code, F2 should have editor.action.rename assigned
When using php, another command may be enabled by specifying when
(You may find it by referring to the keyboard shortcut (Ctrl+kCtrl+s).

If you want to run editor.action.rename, open the command palette (Ctrl+Shift+p) and copy the command ID

Alternatively,

  • Revive F2 from the current keyboard shortcut (assignment)
  • or assign editor.action.rename to another key
  • Using multi-cursors (for example, Ctrl +d)


2023-02-12 16:20

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.