VIM: as autocomplete in CSS file with tag identifiers and class names declared in HTML file

I am trying to execute VIM for editing HTML, CSS and JavaScript. I installed several plugins and configured VIM so that it can autocopy standard HTML / CSS code. And now I want to autocomplete my CSS with tag identifiers and class names placed in HTML files, like Apatan. For instance:

I have a 1.html file with the following lines:

 <div id="my_id"> </div> <div class="my_class"> </div> 

And I have a 1.css file with:

 #my_id{border-style:dotted} .my_class{border-style:solid} 

When I edit the CSS file and press <cx><co> immediately after # , I want VIM to offer me identifier tags from the 1.html file. The same goes for tag class names. What should I do?

+6
source share
2 answers

<Cx><Co> refers to language words such as <table> in the HTML file or background-color in the CSS file, and <Cn> and <Cp> for quick completion of the word.

Suppose your HTML and CSS files are loaded into two buffers (HTML may be hidden or visible in a split), you must enter a couple characters of the name or class name and press <Cn> for a list of possible completions.

Type :help ins-completion for more information.

I use AutoComplPop , which provides real-time completion, but there are other options.

+4
source

I found it helpful to add the following line to my vimrc

 autocmd FileType css,scss set iskeyword=@ ,48-57,_,-,?,!,192-255 

which helps me autofill identifiers and classes with various special characters.

+3
source

Source: https://habr.com/ru/post/898100/


All Articles