VSCode Replace Variable Name Keyboard Shortcut

In MATLAB there is a really nice feature where when you change a variable name in a script it gives you the option to press Shift and Enter to replace all instances of that variable.

Is a keyboard shortcut/feature like this possible in VSCode?

1 Answer

There's a combination of shortcuts:

CTRL + H -> ALT + W -> [Type New Name] -> Enter

  • Highlight the word/variable
  • Hit CTRL + H (Find & Replace)
  • Hit ALT + W (Match whole word)
  • Type in the new name and press enter.

You can hit ALT + C to after CTRL + W if you'd like to match case too if the language is case sensitive.

There's also great answers and alternative methods over on stackoverflow.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like