如何在VScode中删除带有某些关键字的行 [英] How do you delete lines with certain keywords in VScode

查看:350
本文介绍了如何在VScode中删除带有某些关键字的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个正则表达式在一行中查找某些关键字:

I have this regular expression to find certain keywords on a line:

.*(word1|word2|word3).*

在最新 VSCode 的查找和替换功能中,它可以正常工作并找到单词,但它只是将行空白,在中间留下大间隙.

In the find and replace feature of the latest VSCode it works ok and finds the words but it just blanks the lines leaving big gaps in-between.

我想删除包括换行在内的整行.

I would like to delete the entire line including linefeed.

查找和替换功能似乎不支持替换字段中的 reg exp.

The find and replace feature doesnt seem to support reg exp in the replace field.

推荐答案

如果你想删除整行,让你的正则表达式找到整行并包括换行符.类似的东西:

If you want to delete the entire line make your regex find the entire line and include the linefeed as well. Something like:

^.*(word1|word2|word3).*\n

然后 ALT-Enter 将选择所有匹配的行,Delete 将删除它们,包括它们占用的行.

Then ALT-Enter will select all lines that match and Delete will eliminate them including the lines they occupied.

这篇关于如何在VScode中删除带有某些关键字的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆