Sublime Forum

Get xpath at cursor

#1

I am certain to get many snarky “Didn’t you Google that!” responses but I just can not find a tool, plugin, or command to get the xpath at for the current cursor position. I have found at least two that will allow me to move the cursor to a new location in file based on a given xpath which is the exact opposite of what I want to do.

Any advice or assistance will be greatly appreciated!

Shane

0 Likes

#2

http://ndudfield.com/zencoding/old/selection-modifiied.gif

It’s doable. Had a plugin for it on ST1, but to be honest, it wasn’t really much use.

It was cool using xpath/css to create multiple selections though.

The sublime api isn’t really thread safe bar set_timeout to queue callbacks in the main thread.

The way I wrote it was a bit crap so it was a bit bumpy.

I’d planned to rewrite it using generators and set_timeout for ui thread yield points, with cancellation on buffer modifications.

But you know, something shiny or something …

Haven’t ported it to ST2 yet.

0 Likes

#3

Cool, would love to see the implementations of those to compare notes. Do you have links?

0 Likes

#4

this is the github for the search for xpath

github.com/madeingnecca/sublime-xpath-find

0 Likes

#5

This is the last piece of functionality I still have to open notepad++ for.

0 Likes

#6

I’m also looking for this. Any solutions?

0 Likes

#7

I made a plugin that does this. It works in Sublime Text 3, though I have not tested it in ST2.

github.com/rosshadden/sublime-xpath

The one caveat is that it has to be formatted XML. IE each child node has to be indented more than its parents. I honestly don’t work in XML much; I made this for a coworker. Therefore if you want to address this limitation either open an issue or make a pull request.

Also note that it doesn’t have the [4] index at the end of each level because my coworkers said that would actually be counterproductive, and they would just have to strip it out every time they copy a path.

With that said, enjoy!

0 Likes