Dawid Ohia
Dawid Ohia

Reputation: 16445

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).

Upvotes: 27

Views: 15800

Answers (6)

James Bond
James Bond

Reputation: 2996

PHP Tools for Visual Studio Code extension seems to be able to rename functions/vars in PHP.

Upvotes: -1

Jason Cheng
Jason Cheng

Reputation: 330

At the time of this posting, the only way I know of to do this is to buy PHP Intelephese Premium. The free version and the other PHP intellisense plugins do not support rename.

Upvotes: 1

Dawid Ohia
Dawid Ohia

Reputation: 16445

There is an extension called Intelephense extension that provides expected functionality (in paid version as I remember). So I used it for several years in Visual Studio Code and it worked very well.

But I have finally moved to PhpStorm IDE for much more powerful refactoring capabilities and robust PHP support in general.

Upvotes: 5

Maybe this would be helpfull

ext install marsl.vscode-php-refactoring

Install and use Comand line (Ctrl+P) and activate PHP: Rename local variable

Upvotes: 0

Kishore
Kishore

Reputation: 612

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.

Upvotes: 1

Mark
Mark

Reputation: 182046

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.

Upvotes: 11

Related Questions