Search code examples
htmlvimomnicomplete

How to add words to omni completion dictionary?


For example, if I'm in an html file and it type < then tab, I'll get a list of !doctypes that I can use. However "<!DOCTYPE html>" is not included, and I would like to add it. How do I go about doing this?


Solution

  • Take a look at this repo for html5 omnicompletion.

    Alternatively, you can copy $VIMRUNTIME/autoload/htmlcomplete.vim to your ~/.vim/autoload folder and edit it there. This will override it with your custom file.

    619a620
    >               \ '!DOCTYPE html>',
    653,657c654,655
    <           if &filetype == 'html' && exists("uppercase_tag") && uppercase_tag == 1 && item !~ 'DOCTYPE'
    <               let item = toupper(item)
    <           endif
    <           if item =~ 'DOCTYPE'
    <               let abbr = 'DOCTYPE '.matchstr(item, 'DTD \zsX\?HTML .\{-}\ze\/\/')
    ---
    >           if item == '!DOCTYPE html>'
    >               let abbr = "DOCTYPE HTML 5"
    659c657,664
    <               let abbr = item
    ---
    >               if &filetype == 'html' && exists("uppercase_tag") && uppercase_tag == 1 && item !~ 'DOCTYPE'
    >                   let item = toupper(item)
    >               endif
    >               if item =~ 'DOCTYPE'
    >                   let abbr = 'DOCTYPE '.matchstr(item, 'DTD \zsX\?HTML .\{-}\ze\/\/')
    >               else
    >                   let abbr = item
    >               endif
    727a733,736
    >       elseif line=~ '<!DOCTYPE html>'
    >           let b:html_omni_flavor = 'html5'
    >           let b:html_doctype = 1
    >           break