Sublime Forum

Autocomplete css classes etc. in HTML

#1

So, let’s say I included a CSS file in my HTML document with the ordinary <link rel="stylesheet" href="css/style.css" />.
I then want my HTML document to autocomplete stuff that I might use from my stylesheet, for example:

In my CSS I might have this:

.container {
  margin-left: auto;
  margin-right: auto;
  width: 960px;
}

I might then have this in my HTML:

<div id="content" class="container"></div>

What I want to do, is to autocomplete “container” in my HTML document, because I took that from my stylesheet. I hope you understand what I mean, is this possible?

0 Likes

#2

Use this plugin made by Noah:

stackoverflow.com/questions/9081 … ther-files

you just need that included file opened in tabs :wink:

0 Likes

#3

How does one use the plugin code from your link? Save it as what/where, for example.

0 Likes

#4

in Sublime click on Tools -> New Plugin … paste that code there and save, restart sublime and it will work :wink:
Btw: try install SublimeCodeIntell … i think it will give you better satisfaction :wink:

0 Likes

#5

Very cool! Thanks!

0 Likes

#6

I can’t get the CodeIntel package to do anything, but this plugin mostly works.

It won’t hint CSS class names that have a hypen in them, however; it cuts the name suggestion at the hyphen.

For example, if the css has “.gallery-header”, then all that’s hinted or completed is “gallery”,

0 Likes

#7

I’m still having trouble getting Sublime Text 2 to autocomplete css classnames for me.

Similar to handycam above, I cant quite get autocomplete to work fully. (hypens in classnames seem to sometimes get pulled in sometimes, but not others)

Without any packages installed, I am getting Sublime to autocomplete classes from a linked (open or not) css file, but it wont match all.
(I’ve also tried other packages “Anyword Completion”, “All Autocomplete”, “SublimeCodeIntell” with no success)

Here’s an example of how Dreamweaver pulls in all, but Sublime doesnt:

**(Don’t flame me :smile: ** Obviously Dreamweaver is not an ideal choice of editor - hence why I’m asking how to get this working in Sublime :smile:

Does anyone have this working seamlessly? Could you tell me what settings/package you use?

cheers, Pete

0 Likes

#8

problem solved - see this thread: Auto-complete for CSS Class and ID names

0 Likes

#9

[quote=“Frenzy”]in Sublime click on Tools -> New Plugin … paste that code there and save, restart sublime and it will work :wink:
Btw: try install SublimeCodeIntell … i think it will give you better satisfaction :wink:[/quote]

Good plugin, but +1000000 for suggesting SublimeCodeIntel. Very good plugin.

0 Likes