首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在vim中分离合并的html标签?

如何在vim中分离合并的html标签?
EN

Stack Overflow用户
提问于 2012-10-28 09:10:05
回答 2查看 64关注 0票数 1

如何获取此信息:

代码语言:javascript
复制
<body>
    <div>[cursor here]</div>
</body>

要这样做:

代码语言:javascript
复制
<body>
    <div>
        [cursor here]
    </div>
</body>

在一条命令中?我已经安装了sparkup插件,但没有遇到任何这样做的操作

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-10-28 09:21:38

下面是什么:

代码语言:javascript
复制
inoremap <c-k> <cr><esc>O

和ofc将<c-k>更改为您喜欢的任何内容。

票数 1
EN

Stack Overflow用户

发布于 2012-10-28 16:46:54

代码语言:javascript
复制
    :%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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13105557

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档