Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 如何使用特定模式在Vim中的每行末尾添加文本?_Regex_Vim_Macvim - Fatal编程技术网

Regex 如何使用特定模式在Vim中的每行末尾添加文本?

Regex 如何使用特定模式在Vim中的每行末尾添加文本?,regex,vim,macvim,Regex,Vim,Macvim,我的yaml文件: colors - black - white - red - green size - big - small - medium weight - 100 - 200 - 300 如何将“:”添加到不是以“-”开头的每行末尾 结果应该是这样的: colors: - black - white - red - green size: - big - small - medium weight: - 100 - 200 - 300 这

我的yaml文件:

colors
-  black
-  white
-  red
-  green
size
-  big
-  small
-  medium
weight
-  100
-  200
-  300

如何将“:”添加到不是以“-”开头的每行末尾

结果应该是这样的:

colors:
-  black
-  white
-  red
-  green
size:
-  big
-  small
-  medium
weight:
-  100
-  200
-  300
这应该起作用:

:%v/^-/normal A:
本着剥皮猫的精神(感谢你带来了一些幽默,罗曼因:)

这应该起作用:

:%v/^-/normal A:
本着剥皮猫的精神(感谢你带来了一些幽默,罗曼因:)


您可以使用以下选项:

:v/^-/norm A:

您可以使用以下选项:

:v/^-/norm A:

给猫剥皮很有趣:

:v/^-/s/$/:
:%s/^[^-].*/&:

给猫剥皮很有趣:

:v/^-/s/$/:
:%s/^[^-].*/&:

谢谢您。我投了赞成票,但接受了R Sahu的回答,因为他是第一个。谢谢。我投了赞成票,但接受了R Sahu的回答,因为他是第一个。你可以删除
%
。你可以删除
%