vim:删除多行的前 2 个空格 [英] vim: delete the first 2 spaces for multiple lines
本文介绍了vim:删除多行的前 2 个空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 VIM 删除每行前 2 个空格的最简单方法是什么?基本上它对每一行重复2x".
What's the easiest way to delete the first 2 spaces for each line using VIM? Basically it's repeating "2x" for each line.
澄清:这里的假设是前 2 个字符是空格.所以问题是关于对多行一起做缩进.
Clarification: here the assumption is the first 2 characters are spaces. So the question is about doing indentation for multiple lines together.
推荐答案
更多选项.您可以决定哪种方法是最简单的方法".
Some more options. You can decided which is the "easiest way".
删除每行的前 2 个字符:
:%normal 2x
删除每行的前 2 个字符,仅当它们是空格时:
:%s/^ /
注意最后一个斜杠是可选的,只有在这里才能看到两个空格.没有斜线,只有 7 个字符,包括 :
.
Note that the last slash is optional, and is only here so that you can see the two spaces. Without the slash, it's only 7 characters, including the :
.
将每一行的缩进向左移动:
:%normal <<
这篇关于vim:删除多行的前 2 个空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文