如何在vim编辑器中使用sed来替换模式?

Ita*_*not 0 vim sed nrpe

我有下一个代码:

command[check_ping]=/usr/lib64/nagios/plugins/check_ping -w $ARG1$ -c $ARG2$
command[check_filemtime]=/usr/lib64/nagios/plugins/check_filemtime $ARG1$
command[check_iostat]=/usr/lib64/nagios/plugins/check_iostat $ARG1$ $ARG2$
command[check_open_files]=perl /usr/lib64/nagios/plugins/check_open_files.pl -w $ARG1$ -c $ARG2$
command[check_itai]=/usr/lib64/nagios/plugins/itai
command[check_mem]=perl /usr/lib64/nagios/plugins/check_mem.pl -w $ARG1$ -c $ARG2$_
command[check_uptime]=/usr/lib64/nagios/plugins/check_uptime
command[check_ifstatus]=/usr/lib64/nagios/plugins/check_ifstatus -w $ARG1$ -c $ARG2$
command[check_local_load]=/usr/lib64/nagios/plugins/check_load -w $ARG1$ -c $ARG2$
command[check_local_disk]=/usr/lib64/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
Run Code Online (Sandbox Code Playgroud)

从vim编辑器中,我想"\"在每个$ARG参数之前添加一个转义字符,所以我尝试了这个命令: :81,129!sed -e "/\<\$A/\<\\$A",但是会发生的是这些行(81-129)消失,sed命令中的错误写在第81行,我究竟做错了什么?81-129是文件中的相关行号

sat*_*sat 7

vim可以进行正则表达式搜索和替换.因此,您不需要使用外部工具sed.你可以简单地写为,

:81,129s/ \$ARG/ \\$ARG/g
Run Code Online (Sandbox Code Playgroud)