Monday, July 15, 2019

How to do multi line search and replace with VS Code


We can do multi line search and replace with "Replace in Files" and "Replace". "Replace in Files" is easy and have more features than "Replace".
Multi line string search and replace with "Replace in Files" (Ctrl + Shift + H)
  • Step 1: Open "Menu -> Edit -> Replace in Files" (Ctrl + Shift + H)
  • Step 2: Ener multi line search string in "Search" input. You can copy past multi line string from editor or you can use Shift + Enter to input new line
  • Step 3: Enter multi line replace string in "Replace" input as like Step 2. Focus cursor in Search or Replace input and press enter
  • Step 4: You will see all the matching result below "Replace" input. You can click the result to see the Find/Replace in diff window.
image
image
Multi line string search and replace with "Replace" (Ctrl + H)
Step 1: Open "Menu -> Edit -> Replace" (Ctrl + H)
Step 2: Enable "Use Regular Expression" option which is available at right corner of the search input with ".*" icon
Step 3: Seperate multi line search/replace string with "\n". For example
Find string: Line 1\nLine 2\nLine 3\n
Replace string: Line 11\nLine 22\nLine 31\n
image

Featured posts

How to do multi line search and replace with VS Code

We can do multi line search and replace with "Replace in Files" and "Replace". "Replace in Files" is easy and ...