知识分享
VSCode 批量删除指定匹配的一整行
00 min
2021-11-3
2024-7-18
type
status
date
slug
summary
tags
category
icon
password

问题

有些项目开发者喜欢写一堆 console.log()在代码里面,影响后期调试,可以用 VSCode 来批量删除

解决

在 VSCode 中全局搜索,选择正则匹配,输入 ^.*(console.log).*\n
会匹配console.log开头的那一行包括回车符,然后批量替换成空白即可。
notion image
notion image
{ "version": "5.3.0", "objects": [ { "type": "rect", "version": "5.3.0", "originX": "left", "originY": "top", "left": 0, "top": 0, "width": 900, "height": 383, "fill": "rgba(255,255,255,1)", "stroke": null, "strokeWidth": 0, "strokeDashArray": null, "strokeLineCap": "butt", "strokeDashOffset": 0, "strokeLineJoin": "miter", "strokeUniform": false, "strokeMiterLimit": 4, "scaleX": 1, "scaleY": 1, "angle": 0, "flipX": false, "flipY": false, "opacity": 1, "shadow": null, "visible": true, "backgroundColor": "", "fillRule": "nonzero", "paintFirst": "fill", "globalCompositeOperation": "source-over", "skewX": 0, "skewY": 0, "rx": 0, "ry": 0, "id": "workspace", "selectable": false, "hasControls": false }, { "type": "image", "version": "5.3.0", "originX": "left", "originY": "top", "left": -22.0304, "top": -9.6899, "width": 950, "height": 383, "fill": "rgb(0,0,0)", "stroke": null, "strokeWidth": 0, "strokeDashArray": null, "strokeLineCap": "butt", "strokeDashOffset": 0, "strokeLineJoin": "miter", "strokeUniform": false, "strokeMiterLimit": 4, "scaleX": 1.0253, "scaleY": 1.0253, "angle": 0, "flipX": false, "flipY": false, "opacity": 1, "shadow": null, "visible": true, "backgroundColor": "", "fillRule": "nonzero", "paintFirst": "fill", "globalCompositeOperation": "source-over", "skewX": 0, "skewY": 0, "cropX": 0, "cropY": 0, "id": "3ef7f099-85fc-4703-bd71-d8af8a2d35c8", "selectable": true, "hasControls": true, "src": "https://www.kuaitu.cc/uploads/1717898279780_130742d7ad.png", "crossOrigin": "anonymous", "filters": [] }, { "type": "image", "version": "5.3.0", "originX": "left", "originY": "top", "left": -58.4575, "top": -81.0458, "width": 1046, "height": 383, "fill": "rgb(0,0,0)", "stroke": null, "strokeWidth": 0, "strokeDashArray": null, "strokeLineCap": "butt", "strokeDashOffset": 0, "strokeLineJoin": "miter", "strokeUniform": false, "strokeMiterLimit": 4, "scaleX": 1, "scaleY": 1, "angle": 0, "flipX": false, "flipY": false, "opacity": 1, "shadow": null, "visible": true, "backgroundColor": "", "fillRule": "nonzero", "paintFirst": "fill", "globalCompositeOperation": "source-over", "skewX": 0, "skewY": 0, "cropX": 0, "cropY": 0, "id": "e19fce11-6d54-4d1e-8c78-9a19bb621980", "selectable": true, "hasControls": true, "src": "https://www.kuaitu.cc/uploads/1717898279765_3dca9af12b.png", "crossOrigin": "anonymous", "filters": [] }, { "type": "image", "version": "5.3.0", "originX": "left", "originY": "top", "left": 93, "top": 17, "width": 801, "height": 349, "fill": "rgb(0,0,0)", "stroke": null, "strokeWidth": 0, "strokeDashArray": null, "strokeLineCap": "butt", "strokeDashOffset": 0, "strokeLineJoin": "miter", "strokeUniform": false, "strokeMiterLimit": 4, "scaleX": 1, "scaleY": 1, "angle": 0, "flipX": false, "flipY": false, "opacity": 1, "shadow": null, "visible": true, "backgroundColor": "", "fillRule": "nonzero", "paintFirst": "fill", "globalCompositeOperation": "source-over", "skewX": 0, "skewY": 0, "cropX": 0, "cropY": 0, "id": "265e34f8-b994-48ea-bf16-fda2834fd91f", "selectable": true, "hasControls": true, "src": "https://www.kuaitu.cc/uploads/1717898279745_e89ea41a2b.png", "crossOrigin": "anonymous", "filters": [] }, { "type": "image", "version": "5.3.0", "originX": "left", "originY": "top", "left": 0, "top": 5, "width": 424, "height": 392, "fill": "rgb(0,0,0)", "stroke": null, "strokeWidth": 0, "strokeDashArray": null, "strokeLineCap": "butt", "strokeDashOffset": 0, "strokeLineJoin": "miter", "strokeUniform": false, "strokeMiterLimit": 4, "scaleX": 1, "scaleY": 1, "angle": 0, "flipX": false, "flipY": false, "opacity": 1, "shadow": null, "visible": false, "backgroundColor": "", "fillRule": "nonzero", "paintFirst": "fill", "globalCompositeOperation": "source-over", "skewX": 0, "skewY": 0, "cropX": 0, "cropY": 0, "id": "7f33b82d-928e-4f75-a57a-210fe80b77cd", "selectable": true, "hasControls": true, "src": "https://www.kuaitu.cc/uploads/1717898279727_83c6008c3f.png", "crossOrigin": "anonymous", "filters": [] }, { "type": "textbox", "version": "5.3.0", "originX": "left", "originY": "top", "left": 355.5049, "top": 134.0162, "width": 432.5447, "height": 180.5216, "fill": "rgb(0, 0, 0)", "stroke": null, "strokeWidth": 1, "strokeDashArray": null, "strokeLineCap": "butt", "strokeDashOffset": 0, "strokeLineJoin": "miter", "strokeUniform": false, "strokeMiterLimit": 4, "scaleX": 1, "scaleY": 1, "angle": 0, "flipX": false, "flipY": false, "opacity": 1, "shadow": "", "visible": true, "backgroundColor": "", "fillRule": "nonzero", "paintFirst": "fill", "globalCompositeOperation": "source-over", "skewX": 0, "skewY": 0, "fontFamily": "优设标题黑", "fontWeight": "normal", "fontSize": 73.96, "text": "VSCode \n正则批量删除", "underline": false, "overline": false, "linethrough": false, "textAlign": "left", "fontStyle": "normal", "lineHeight": 1.16, "textBackgroundColor": "", "charSpacing": 0, "styles": [], "direction": "ltr", "path": null, "pathStartOffset": 0, "pathSide": "left", "pathAlign": "baseline", "minWidth": 20, "splitByGrapheme": true, "id": "7893e7d1-2820-47b7-a000-71fae4ea16f5", "selectable": false, "hasControls": false, "editable": true }, { "type": "image", "version": "5.3.0", "originX": "left", "originY": "top", "left": 57.6797, "top": 44.0763, "width": 502, "height": 663, "fill": "rgb(0,0,0)", "stroke": null, "strokeWidth": 0, "strokeDashArray": null, "strokeLineCap": "butt", "strokeDashOffset": 0, "strokeLineJoin": "miter", "strokeUniform": false, "strokeMiterLimit": 4, "scaleX": 0.5451, "scaleY": 0.5451, "angle": 0, "flipX": false, "flipY": false, "opacity": 1, "shadow": null, "visible": true, "backgroundColor": "", "fillRule": "nonzero", "paintFirst": "fill", "globalCompositeOperation": "source-over", "skewX": 0, "skewY": 0, "cropX": 0, "cropY": 0, "id": "170cf0ae-86b5-4367-bbcc-f115e1db6947", "selectable": true, "hasControls": true, "src": "https://www.kuaitu.cc/uploads/download_11_d0b6abf9b7.webp", "crossOrigin": "anonymous", "filters": [] } ], "clipPath": { "type": "rect", "version": "5.3.0", "originX": "left", "originY": "top", "left": 0, "top": 0, "width": 900, "height": 383, "fill": "rgba(255,255,255,1)", "stroke": null, "strokeWidth": 0, "strokeDashArray": null, "strokeLineCap": "butt", "strokeDashOffset": 0, "strokeLineJoin": "miter", "strokeUniform": false, "strokeMiterLimit": 4, "scaleX": 1, "scaleY": 1, "angle": 0, "flipX": false, "flipY": false, "opacity": 1, "shadow": null, "visible": true, "backgroundColor": "", "fillRule": "nonzero", "paintFirst": "fill", "globalCompositeOperation": "source-over", "skewX": 0, "skewY": 0, "rx": 0, "ry": 0, "selectable": true, "hasControls": true } }
上一篇
使用 Github Actions 自动部署代码
下一篇
Vue 项目的 Nginx 基础配置