删除每行的第一个单词 [英] Delete first word of each line

查看:23
本文介绍了删除每行的第一个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Vim 中删除每行的第一个单词?

How do I delete first word of each line in Vim?

每一行的图案怎么样?

推荐答案

我会使用类似以下内容:

I would use something like the following:

:%s/^\w+\s+//

正则表达式将匹配从行首开始的一个或多个单词"字符,后跟至少一个空格字符.它将删除单词和任何后面的空格.如果一行只能包含一个单词——而您仍然希望将其删除——您可以使用交替来匹配空格或行尾.

The regular expression will match one or more "word" characters starting at the beginning of the line followed by at least one whitespace character. It will remove the word and any following whitespace. If a line can contain only a single word -- and you still want it removed -- you could use alternation to match either whitespace or the end of line.

:%s/^\w+(\s+|$)//

这篇关于删除每行的第一个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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