Remove all console.log statements at once
- Open the global search and replace function in your editor.
- Enable the Regular Expression (Regex) mode by clicking the .* icon in the search bar.
- In the Find input field, use one of the following regular expressions:
console\.log\(.*\);? (for single-line console.log statements)
console\.log\(([^)]+)\);? (for single or multi-line statements)
console\.(log|warn|error|info)\(.*?\);? (to target all console methods)
- Leave the Replace input field empty to delete the matches.
- Click the "Replace All" button.