Sublime Forum

Notify of duplicate ID's?

#1

Hello, can sublime text notify you, if you are using an ID more than once? aka. “id redefinition”

<div id=“test”></div>
<div id=“test”></div>

0 Likes

#2

Assuming that you are working with well-formed XHTML, you could manually check using the XPath plugin.

  1. Install the XPath plugin from Package Control.
  2. Open the Command Palette
  3. Type XPath: Query and select XPath: Query Document
  4. Enter this expression: //*[@id and (@id=./preceding::*/@id or @id=./following::*/@id)]
  • If there are no duplicate id’s, it won’t show anything, and in the status bar, it was say 0 results from query
  • If there are duplicate id’s, it will show them, and you can navigate to the elements that contain them
1 Like

#3

Thanks I’ll give that a try. However I was hoping to find a more automated solution. The sublime-linter plugins looked promising, but didn’t appear to check for duplicate ID’s .

I have been trying to make the switch from Dreamweaver to Sublime. It’s going alright, but live error reporting was something I relied on heavily in Dreamweaver.

0 Likes

#4

This linter plugin seems to do it:

1 Like

#5

Oh, awesome! Thank you.

0 Likes