我如何得到这个:
<body>
<div>[cursor here]</div>
</body>
对此:
<body>
<div>
[cursor here]
</div>
</body>
在一个命令中?我安装了sparkup插件,但没有遇到任何执行此操作的操作
答案 0 :(得分:1)
怎么样:
inoremap <c-k> <cr><esc>O
和ofc将<c-k>
更改为您喜欢的任何内容..
答案 1 :(得分:0)
:%s/\(>\_\s\+<div>\)\([^<]*\)\(.*\)/\1\r\t\t\2\r\t\3/g
: .................. command line
% .................. whole file
/ .................. start search pattern
\( ................. start group -- see \) closing at the end
> .................. one close tag
\_ ................. multiline search
\s ................. one space
\+ ................. or more
<div> .............. one div
\) ................. closing group one
\( ................. open the second group
[^<]* .............. denied list in wich no has open tag < (everything less <)
\) ................. closing the second group
\( ................. opening the third group (everything else) in the next line
.* ................. the rest of line, including the close </div>
/ .................. start of substitution pattern
\1 ................. back reference to the group one (place them here)
\r ................. carriage return (or simply <enter>)
\t\t ............... 2 tabs
\2 ................. place second group here
\r ................. another <enter>
\t ................. one more tab
\3 ................. palce third group here
/ .................. end of substituition
g .................. global command