Question

I am using the vim console on windows.

Is there any good extension out there to autocmatically close HTML and/or CSS and possibly jquery tags?

like in eclipse when i got <p i press ctrl+space and it automatically puts me <p> </p> ?

Was it helpful?

Solution

Vim comes with an auto complete of ctrl+p and ctrl+n.

It is for the variables and functions you have written.

If you want to add support for tags and jQuery / JavaScript functions you might want to create a text file, write all of the functions you use and want (After all, most of us use a small subset of each library we utilize) And then just load the file when an HTML file is created / loaded like so:

autocmd BufNewFile,BufRead *`<extention>` badd `<dir to file>`

the extension in your case can be .html or .js

Edit: If you don't want to do it yourself, try this: https://github.com/rogeliog/Vim-Snippets

And possibly read this question: How do I get vim to autocomplete my jQuery code?

Edit2: If you want to have the autocomplete with ctrl + space, try this:

inoremap <expr> <C-Space> pumvisible() \|\| &omnifunc == '' ?
\ "\<lt>C-n>" :
\ "\<lt>C-x>\<lt>C-o><c-r>=pumvisible() ?" .
\ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" .
\ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>"
imap <C-@> <C-Space>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top