Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename refactoring for PHP in Visual Studio Code

Is there a rename refactoring for PHP in Visual Studio Code? It is the only thing that stops me from fully move from NetBeans to VSC. Renaming is very importat for me (not search/replace).

like image 900
Dawid Ohia Avatar asked Oct 13 '17 13:10

Dawid Ohia


People also ask

What is refactoring code PHP?

PHP code refactoring Last modified: 14 July 2022. Refactoring means updating the structure of the source code without changing the behaviour of the application. Refactoring helps you keep your code solid, dry, and easy to maintain.

Is renaming variable refactoring?

Refactoring variable names involves renaming the variable and then updating usages of the variable that occur elsewhere, such as in the pipeline, other flow services, or document types.

How do I rename a Refactor in Visual Studio?

Select Edit > Refactor > Rename. Right-click the code and select Rename.


2 Answers

There are

{
  "command": "editor.action.changeAll",
  "key": "ctrl+f2",
  "when": "editorTextFocus && !editorReadonly"
}

and

{
  "command": "editor.action.rename",
  "key": "f2",
  "when": "editorHasRenameProvider && editorTextFocus && !editorReadonly"
}

in the keybindings. F2 appears to work across all files, CTRL-F2 in the current file only.

like image 118
Mark Avatar answered Oct 19 '22 14:10

Mark


Try this rename symbol instead of the standard find/replace. Rename is bound to F2 for all files, CTRL - F2 for current file, may require installing a php language extension.

like image 2
Kishore Avatar answered Oct 19 '22 12:10

Kishore