我有多行纯文本,每行混有带/不带双引号的短语。我想删除所有包含引号的内容,但保留双引号中的内容。 示例:
int (*)[1][2]
结果应为:
/// <summary>
/// Create a list of the given anonymous class. <paramref name="definition"/> isn't called, it is only used
/// for the needed type inference. This overload is for when you don't have an instance of the anon class
/// and don't want to make one to make the list.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="definition"></param>
/// <returns></returns>
#pragma warning disable RECS0154 // Parameter is never used
public static List<T> CreateListOfAnonType<T>(Func<T> definition)
#pragma warning restore RECS0154 // Parameter is never used
{
return new List<T>();
}
/// <summary>
/// Create a list of the given anonymous class. <paramref name="definition"/> isn't added to the list, it is
/// only used for the needed type inference. This overload is for when you do have an instance of the anon
/// class and don't want the compiler to waste time making a temp class to define the type.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="definition"></param>
/// <returns></returns>
#pragma warning disable RECS0154 // Parameter is never used
public static List<T> CreateListOfAnonType<T>(T definition)
#pragma warning restore RECS0154 // Parameter is never used
{
return new List<T>();
}
答案 0 :(得分:2)
:%s/.*\"\(.*\)\".*/\1
说明
REPLACE, ANY_STRING, QUOTES, CAPTURE_ANY_STRING, QUOTES, ANY_STRING WITH
:%s/ .* \" \( .* \) \" .* . /\1
答案 1 :(得分:1)
如果光标位于该行的开头,则可以执行以下操作:
f"lyi"Vp
f"l
将光标移到“第一个”,然后再留出一个空格
yi"
将s中的所有内容移至匿名注册人
Vp
在可视模式下选择整行,然后在其上粘贴匿名寄存器
要应用于多行,请使用normal
命令。
:%normal 0f"lyi"Vp
:
进入命令模式
%
将范围设置为整个文件
normal
执行以下击键,就像在普通模式下一样输入
0
将光标移动到行首
f"lyi"Vp
参见上文