SlickEdit Product Discussion > SlickEdit®

auto-completing current XML element

(1/2) > >>

ronburk:
I increasingly find myself typing custom XML documents with lengthy element names like <SectionHeading>, and I would sure like to find a keystroke that just automatically supplies the end tag for the element I'm in the midst of. In other words, if the nearest unclosed element to the left of my cursor is "<SectionHeading>", I would like to hit a key that automatically inserts a "</SectionHeading>".

I'm guessing that functionality is in VS 11.0 already and I just haven't found it. Is there such a function already, or would that require some custom coding?

Matthew:
Yes, this feature is in v11. You have to make sure the file extension you're working with is mapped as XML. Go to Tools | Options | File Extension Setup, and create a new extension. Then just have that extension refer to XML.
Now, there isn't a hotkey per-se. Just enter the first part of the closing tag (ie - type </), and it'll take it from there. I edit a heck of a lot of NAnt buildfiles in SE, and this autocomplete feature is must-have.

ronburk:
Well, I'm using v11 to edit a .xml file, and typing the "</" seems to do nothing for me at all.

At that point, the little listbox in the rebar area says "no current context" (not sure what that means).

If you're getting something useful to happen, then I would have guessed we have different options set in the "Auto-Complete" tab of the "Extension Options" for ".xml". But, staring at and tinkering with those options brings me no change in this behavior.

I have checked "Enable auto-completion" and "Keywords" and "Alias expansion" and "Symbols" and "Word completion".

If I type a character after the "</", then it does try to do some kind of auto-completion, but it seems to have no concept that there's only one possible legal tag it can be at that point. It offers me choices that include most any word of text with the same prefix that appears in the file.

Anything else I might try to get this feature enabled? Is it possible this just doesn't work on well-formed XML, and requires a DTD or some other aspect of "valid" (as opposed to "well-formed", as defined by the standard) XML?

gavink:

--- Quote from: ronburk on July 12, 2006, 04:41:16 AM ---Anything else I might try to get this feature enabled? Is it possible this just doesn't work on well-formed XML, and requires a DTD or some other aspect of "valid" (as opposed to "well-formed", as defined by the standard) XML?

--- End quote ---

Well, I am confused. I have been using SlickEdit to edit XML files since about version 9 and typing </ has always been enough for me. AFAIK they only criteria is having well formed XML (in fact, it does not have to be well formed since by definition you do not have a closing tag for your element yet). No DTD or schema is required. Sorry I cannot help.

ronburk:
Thanks guys. Just knowing it's supposed to work gives me the energy to try to figure this out. I'll start by getting the latest patch, then start trying to understand where the magic code lies and why it's not getting invoked. Maybe it's some forgotten self-inflicted tweak that I did to myself ages ago.

Navigation

[0] Message Index

[#] Next page

Go to full version