Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top