1

我怎么得到这个:

<body>
    <div>[cursor here]</div>
</body>

对此:

<body>
    <div>
        [cursor here]
    </div>
</body>

在一个命令中?我安装了 sparkup 插件,但没有遇到任何执行此操作的操作

4

2 回答 2

1

关于什么:

inoremap <c-k> <cr><esc>O

并且ofc更改<c-k>为您喜欢的任何内容..

于 2012-10-28T01:21:37.670 回答
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
于 2012-10-28T08:46:54.383 回答