如何仅在当前行中搜索和替换? [英] How to search and replace in current line only?

查看:37
本文介绍了如何仅在当前行中搜索和替换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到如何在特定行中搜索和替换,按行号指定,以及 如何搜索和替换使用当前行作为对向下行数的引用.

I see how to search and replace in specific lines, specifying by line number, and how to search and replace using the current line as reference to a number of lines down.

如何仅在当前行中搜索和替换?我正在寻找一种简单的解决方案,它不像链接的解决方案那样涉及指定行号.

How do I search and replace in the current line only? I'm looking for a simple solution that does not involve specifying line numbers as the linked solutions do.

推荐答案

将特定行中所有出现的 str1 替换为 str2:

Replace all occurrences of str1 with str2 in certain line:

:s/str1/str2/g

如果您只想替换第一次出现,请删除 g 选项.

remove the g option if you want to replace only the first occurrence.

这篇关于如何仅在当前行中搜索和替换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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