Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete/Replace same (code)word in one go from Visual Studio code

Let's say if (click)="toggle()" is written 10 times in same file, how can I delete/replace the same piece of code in one go?

When I select above piece of code, VSCode automatically highlights same code but how to delete/replace it in one go?

Is it possible to delete/replace same piece of code in one go using VS Code?

like image 637
Nikhil Shah Avatar asked Jan 24 '17 14:01

Nikhil Shah


People also ask

How do I replace a text in Visual Studio Code?

Visual Studio Code v 1.3.0++ has this feature: Replace functionality can be accessed: In the Search View by expanding the Search textbox Using Ctrl + Shift + H, from the Edit | Replace in Files menu

How to delete/change text in a code in one go?

1 Select the code you want to replace. 2 Execute editor.action.addSelectionToNextFindMatch (on Windows it's on CTRL + d by default) until all occurences are selected OR execute actions.find ( ... 3 Now you have multiple cursors active and you are able to delete/change the text in one go.

Can search and replace be used across all files in VS Code?

You can search and replace across all the files in your workspace. Note that if you did not open VS Code on a folder, the search will only run on the currently open files. How do I turn on word wrap?

Is it possible to replace a group in VS Code?

VS Code also supports capturing groups when using regex, captured groups ( using parenthesis) can be referenced with $1 for the first match, $2 the second etc. $0 returns the complete match. It's currently not possible to replace in all files.


1 Answers

Multiple selections (multi-cursor)# VS Code supports multiple cursors for fast simultaneous edits. You can add secondary cursors (rendered thinner) with Alt+Click. Each cursor operates independently based on the context it sits in. A common way to add more cursors is with ⌥⌘↓ or ⌥⌘↑ that insert cursors below or above.

Note: Your graphics card driver (for example NVIDIA) might overwrite these default shortcuts. multicusor gift vscode

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

enter image description here

Tip: You can also add more cursors with ⇧⌘L, which will add a selection at each occurrence of the current selected text.

like image 96
Alfredo-Rojas Avatar answered Sep 21 '22 14:09

Alfredo-Rojas