Selasa, 26 Maret 2019

Delete All Comments in a File With VS Code

What if you want to delete all comments in a file with VS Code? VS Code has a find and replace feature that support regular expression, so we can use that feature to automatically find line starting with hash (#), Here we go: 1. Press ctrl + f 2. Click on "Use regular expression" button on "find and replace" widget 3. Type the regular expression: ^#.*$\n 4. Leave the "Replace" field empty 5. Click "Replace All" button And all of your comment deleted, actually it is replaced by the empty character. Notes ^#.*$\n : • ^ = matches position just before the first character of the string • # = character that we want to find • . = matches a single character. Does not matter what character it is, except newline • * = matches preceding match zero or more times • $ = matches position just after the last character of the string • \n = Line feed character

Tidak ada komentar:

Posting Komentar