vi比较文本 -vim_Vim,Vi Search使用示例查找和替换文本教程

vi比较文本 -vimVim is a powerful tool for text editing code developments etc. One of the most wanted and loved features is to find and replace a simple substitute. We will look at different ways to find a...
摘要由CSDN通过智能技术生成
vi比较文本 -vim

vi比较文本 -vim

Vim is a powerful tool for text editing code developments etc. One of the most wanted and loved features is to find and replace a simple substitute. We will look at different ways to find and replace operation in vim. Our text file named file1 is like below.

Vim是用于文本编辑代码开发等功能的强大工具。最需要和最喜欢的功能之一是找到并替换一个简单的替代品。 我们将研究在vim中查找和替换操作的不同方法。 我们的名为file1文本文件如下所示。

This is line 1 
We can resume 
Extra file 
Change the station

只需替换为Vim (Simply Replace with Vim)

To work with replace function we need to open the text file with vim and then run replace command.

要使用替换功能,我们需要使用vim打开文本文件,然后运行replace命令。

:%s/line/LINE/g
Simply Replace
只需更换
  • %s will look at all lines for /line occurrence

    %s将查看所有行中是否存在/行

  • /LINE will be replaced with /g flag.

    / LINE将替换为/ g标志。

单行替换 (Replace In Single Line)

If we want to replace only in a single line, not in the whole file we will remove % from command like below. We will change LINE to the line

如果我们只想在一行中而不是整个文件中进行替换,我们将如下所示从命令中删除%。 我们将LINE更改为该

:s/LINE/line/g
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值