Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vim 如何在`{`和`}`之间的行中添加四个空格?_Vim_Format - Fatal编程技术网

Vim 如何在`{`和`}`之间的行中添加四个空格?

Vim 如何在`{`和`}`之间的行中添加四个空格?,vim,format,Vim,Format,目标文本文件 <style type="text/css"> #wrap{ height: 550px; width: 660px; } #wrap ul{ list-style: none; } #wrap li{ border-radius:3px; cursor:pointer; } #wrap{ height: 550px; width: 660px; } #wrap ul{ list

目标文本文件

<style type="text/css">
  #wrap{ 
  height: 550px; 
  width: 660px; 
  }
  #wrap ul{ 
  list-style: none; 
  }
  #wrap li{ 
  border-radius:3px; 
  cursor:pointer; 
  }
  #wrap{ 
  height: 550px; 
  width: 660px; 
  }
  #wrap ul{ 
  list-style: none; 
  }
  #wrap li{ 
  border-radius:3px; 
  cursor:pointer; 
  }
</style> 
也许执行所有的公共任务是愚蠢的

3,4s/^/    /g
7s/^/    /g
10,11s/^/    /g
14,15s/^/    /g
18s/^/    /g
21,22s/^/    /g

还有更简单、更智能的方法吗?

假设文档的文件类型已正确设置为html,并且制表设置正确,以下内容就足够了:

:2,23norm ==
但是,要直接回答您的问题,您应该针对以下行:

如果不想手动定义范围,可以执行以下操作:

vit:g/:/s/^/    /
其中插入了 这意味着返回

:2,23g/:/s/^/    /
vit:g/:/s/^/    /
:g/^[^<#}]/ normal >>
: ........... command
g ........... global command (executes on the following pattern
/ ........... start search pattern
^ ........... beginning of line
[^ ] ........ denied list 
<#} ......... denied chars
/ ........... search pattern's end
normal ...... execute in normal mode
>> .......... indentation
map <F2> <esc>:g/^[^<#}]/ normal >><cr>