如何让 vim 的 closetag 插件适用于所有 html 标签?

发布于 2024-08-05 11:25:23 字数 212 浏览 3 评论 0原文

我正在使用 closetag.vim 插件,但它似乎不适用于所有标签。在插件代码中,有一个被忽略的标签 var,其中包含一些我注意到没有关闭 ex dd dl 的标签,但还有许多其他标签不在列表中,无法正常工作(p、ul、li)。

更新忽略标签列表后似乎没有发生任何事情。

要让这个插件工作,你只需输入标签文本并单击选项卡,对吗? ie div

我错过了什么吗?

I am using the closetag.vim plugin, but it doesn't seem to work for all tags. In the plugin code there is the ignored tags var that contains some one that I noticed were not closing ex dd dl, but there are many others that aren't in the list that are not working (p, ul, li).

Nothing seemed to happen after updating the list of ignored tags.

To get this plugin to work you just enter the tag text and click tab, right? ie div

Am I missing something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

再见回来 2024-08-12 11:25:23

你是如何安装插件的?

当我将 closetag.vim 安装在 ~/.vim/plugins 中时,我遇到了问题。然后我将其移至 ~/.vim/scripts 中,并将以下内容添加到我的 .vimrc 中:

:let g:closetag_html_style=1
:source ~/.vim/scripts/closetag.vim

现在它对我来说工作得很好。我发现它关闭所有标签(包括“忽略”列表中包含的标签),但不关闭那些自动关闭的标签(例如 )。

在我使用的脚本版本(0.9.1)中,它将 定义为完成标签的触发器。如果您已将命令映射到 ,那么这也应该有效。

How did you install the plugin?

I had troubles with closetag.vim when I installed it in ~/.vim/plugins. Then I moved it into ~/.vim/scripts instead, and added the following to my .vimrc:

:let g:closetag_html_style=1
:source ~/.vim/scripts/closetag.vim

and now it works fine for me. I find that it closes all tags (including those included in the 'ignore' list), but not those that are self-closing (e.g. <img/>).

In the version of the script that I am using (0.9.1), it defines <C-_> as the trigger for completing tags. If you have mapped the command to <tab>, then that should work too.

徒留西风 2024-08-12 11:25:23

我也无法让这个插件工作,但是就我而言,它的作用是在最终工作之前抛出许多错误消息。例如,如果我尝试关闭 H1 标签,我将收到错误处理函数 GetCloseTag 时检测到错误,并且错误是未定义的变量 b:UnaryTagsStack

看起来这将是一个有用的插件,但它就是不合作。

I also cannot get this plugin to work, however in my case what it does it throw out a number of error messages before finally working. For instance if I try to close an H1 tag I will get the error Error Detected while processing function GetCloseTag and the error is an undefined variable b:UnaryTagsStack.

Seems like it would be a useful plugin but it just won't cooperate.

日记撕了你也走了 2024-08-12 11:25:23

我遇到了同样的问题,纳尔斯特罗姆上面的回答并没有为我解决。对我有用的是将以下几行添加到我的 .vimrc 中:

if !exists("b:unaryTagsStack") || exists("b:closetag_html_style")
    if &filetype == "html" || exists("b:closetag_html_style")
        let b:unaryTagsStacktack="area base br dd dt hr img input link meta param"
    else " for xml and xsl
        let b:unaryTagsStack=""
    endif
endif

if !exists("b:unaryTagsStack")
    let b:unaryTagsStack=""
endif

我不知道为什么仅添加 let b:unaryTagsStack="" 并没有解决问题,但上面的组合似乎可以修复它对我来说适用于所有文件类型。

I had the same issue and nelstrom's answer above didn't solve it for me. What worked for me was adding the following lines to my .vimrc:

if !exists("b:unaryTagsStack") || exists("b:closetag_html_style")
    if &filetype == "html" || exists("b:closetag_html_style")
        let b:unaryTagsStacktack="area base br dd dt hr img input link meta param"
    else " for xml and xsl
        let b:unaryTagsStack=""
    endif
endif

if !exists("b:unaryTagsStack")
    let b:unaryTagsStack=""
endif

I don't know why adding just let b:unaryTagsStack="" didn't do the trick, but the combination above seems to fix it in all file types for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文