linux - Vim 正则表达式查找和替换

标签 linux vim

我必须找到具有这种模式的单词:

File{some numeric characters}=  

示例:File1=File234=File3456= 并删除它们。

这是一行:

File1=/media/sda5/  

现在我必须将这一行替换为:

/media/sda5/  

由于我是vim的新手,所以如果有人能帮助我

最佳答案

这个命令应该做你想做的:

:%s/File\d\+=//g

:%s/         perform substitution on each line in the buffer
File\d\+=    matches 'File' followed by one or more digits until the first '='
//           deletes the matched text
g            do that on every match on the line

关于linux - Vim 正则表达式查找和替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27091389/

相关文章:

c - 使用 execl 获取 grep 值

.net - 自定义 UI - Windows 还是 Linux?

java - 为什么 paintComponent 从未被调用?

Vim - 转到上一个位置

vim - vim 上的不同配色方案

linux - 关于 rfc 的系统日志问题

linux - sock_sendmsg() : implicit function calls by Kernel

git - 如何为目录和目录外的文件创建 git 存储库?

linux - 变量在 vim 中打印正常,但在 bash shell 中却不行,这是怎么发生的?

Vim:如何在激活的搜索模式下立即更改设置 'iminsert' 和 'imsearch' ?