如何使用 vi 计算每行的列数?
我有一个文件,每行应该有 8 列。但显然有几行有一个额外的“选项卡”。是否可以在 vi
中仅搜索包含超过 8 列的行,以便解决问题?
I have a file which is supposed to have exactly 8 columns on each line. But apparently there are a few lines that have an extra 'tab'. Is it possible in vi
to search for only those lines that contain column more than 8 so that the problem can be fixed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要搜索任何超过 8 个字符的行,请尝试
/^.\{8}.\+$
逐步
/
- 开始搜索^ - 表示“行的开头”
.
- 任何字符\{8}
- 前面匹配的 8 个(在本例中...“任何字符”).
- 任何字符\+
- 1 个或多个前面的匹配$
- 行尾To search for any line with more than 8 characters try
/^.\{8}.\+$
Step by step
/
- start a search^
- means "beginning of the line".
- any character\{8}
- 8 of the preceding match (in this case... "any character").
- any character\+
- 1 or more of the preceding match$
- end of the line尝试以下
/
搜索:(即 9 个句点)
Try the following
/
search:(that's 9 periods)