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?
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
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.
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?
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.
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.
⌘D selects the word at the cursor, or the next occurrence of the current selection.
Tip: You can also add more cursors with ⇧⌘L, which will add a selection at each occurrence of the current selected text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With