How do I get this:
我怎么得到这个:
<body>
<div>[cursor here]</div>
</body>
To this:
对此:
<body>
<div>
[cursor here]
</div>
</body>
In a single command? I have the sparkup plugin installed but didn't come across any actions that do this
在一个命令?我安装了sparkup插件但没有遇到任何执行此操作的操作
2 个解决方案
#1
1
what about:
关于什么:
inoremap <c-k> <cr><esc>O
and ofc change <c-k>
to whatever you like..
和ofc将
#2
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
#1
1
what about:
关于什么:
inoremap <c-k> <cr><esc>O
and ofc change <c-k>
to whatever you like..
和ofc将
#2
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