Sublime Forum

CSS Autocomplete selectors

#1

I like the fact that Sublime Text will allow you to enter text and it will suggest variables that have been used in that file already (like in JS & PHP files). Is there a way that this can be achieved with CSS selectors? Say if I declare:

#main{ display: block; }

Is there a way to set up ST so that when I then type “#ma” it will suggest “main”?

This would be useful for code like (for example):

#main{
 display: block;
}
#main h2{
 font-size: 10px;
}
#main span{
 display: block;
}
#main span p{
 padding: 5px 0;
}
0 Likes

#2

bump

“Post must be at least 10 characters”. Ok.

0 Likes

#3


it worked for me to just use PackageResourceViewer to edit Packages/CSS/Completion Rules.tmPreferences and comment out the .*: <!--.*-->, then typing #m in the OP snippet suggests main

2 Likes

#4

Yes. Figured out the same as well from the patch given in Github.

Details here: https://sridhar.blog/enable-autocomplete-css-selectors-sublime-text/

0 Likes