Selecting XML and HTML blocks

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Selecting XML and HTML blocks

Bram Moolenaar

I have added a new feature in the snapshot uploaded last night: the "at"
and "it" text objects.  The names stand for "A Tag" and "Inner Tag".

These text objects are most useful when editing HTML, SGML and XML
files.  When the cursor is in a start tag, say <b>, then "vat" will
select the text up to and including the matching </b>.  "vat" als works
when the cursor is in the text or on the </b>.
(there is no relation with tax! :-)

"vit" will select the same text but excludes the tags.

In Visual mode you can repeat "at" and "it" to expand the selection to
the containing block.  This goes on until <html> to </html> is selected.

XML tags in the form <aaa/> are ignored, since they don't come in
pairs.  For HTML there are also non-paired tags, but this is not
obvious.  They are ignored if a matching tag can't be found.

Give it a try.  I'm no expert on HTML or XML syntax, there may be
situations where it doesn't work well.  In that case suggest how it
should work.

--
BLACK KNIGHT:  Come on you pansy!
    [hah] [parry thrust]
    [ARTHUR chops the BLACK KNIGHT's right arm off]
ARTHUR:        Victory is mine!  [kneeling]
               We thank thee Lord, that in thy merc-
    [Black Knight kicks Arthur in the head while he is praying]
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

A.J.Mechelynck
----- Original Message -----
From: "Bram Moolenaar" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, July 20, 2005 1:38 PM
Subject: Selecting XML and HTML blocks


>
> I have added a new feature in the snapshot uploaded last night: the "at"
> and "it" text objects.  The names stand for "A Tag" and "Inner Tag".

Great idea!

>
> These text objects are most useful when editing HTML, SGML and XML
> files.  When the cursor is in a start tag, say <b>, then "vat" will
> select the text up to and including the matching </b>.  "vat" als works
> when the cursor is in the text or on the </b>.
> (there is no relation with tax! :-)
>
> "vit" will select the same text but excludes the tags.
>
> In Visual mode you can repeat "at" and "it" to expand the selection to
> the containing block.  This goes on until <html> to </html> is selected.
>
> XML tags in the form <aaa/> are ignored, since they don't come in
> pairs.  For HTML there are also non-paired tags, but this is not
> obvious.  They are ignored if a matching tag can't be found.

The recent tendency in HTML is XHTML, i.e., documents which can be treated
as either HTML or XML depending on circumstances. The difference with
"classical" HTML is that unpaired tags have a / just before the closing >.
(In XML, all tags must be paired unless that slash is present.)

In HTML, some tags (like META, BR, HR, ...) are always unpaired, others
(like P, LI, ...) are optionally paired. I could scrap up a list if I
weren't this lazy... well, on second thought it shouldn't be that hard:

Always paired: A, ABBR, ACRONYM, ADDRESS, APPLET, B, BDO, BIG, BLINK,
BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COLGROUP, COMMENT,
DEL, DFN, DIR, DIV, DL, EM, FIELDSET, FONT, FORM, FRAMESET, H1, H2, H3, H4,
H5, H6, HEAD, I, IFRAME, INS, KBD, LABEL, LAYER, LEGEND, LISTING, MAP,
MARQUEE, MENU, MULTICOL, NOBR, NOFRAMES, NOSCRIPT, OBJECT, OL, OPTGROUP,
PLAINTEXT, Q, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, STYLE,
SUB, SUP, TABLE, TBODY, TEXTAREA, TFOOT, THEAD, TITLE, TT, U, UL, VAR, XMP

Optionally paired: DD, DT, LI, P, TD, TH, TR

Always unpaired: AREA, BASE, BASEFONT, BGSOUND, BR, COL, EMBED, FRAME, HR,
HTML, IMG, INPUT, ISINDEX, LINK, META, OPTION, PARAM, SPACER, WBR

HTML is an evolving language, however. Some of the above are rare, some are
deprecated or obsolete in newer versions of the language, and some are only
recognised by some browsers but not all. Also, the reference I use has a
copyright date of 2000 and covers HTML versions until 4.0: tags which were
"invented" later than that are not listed, though some "unofficial" ones
are. You can find a "typical" list of unpaired HTML tags as, for instance,
the default for the user-settable variable b:unaryTagsStack when editing
HTML files with the CloseTag plugin (closetag.vim,
http://vim.sourceforge.net/scripts/script.php?script_id=13 ). I suppose that
the simplest thing to do would be, as you say, to ignore an
optionally-unpaired tag unless its closing counterpart is found. (When the
cursor is on a _closing_ optionally-unpaired tag such as </P> its
counterpart must of course always be found.) A refinement would be to use
b:unaryTagsStack if it exists, and flag mismatches as errors for any tags
not listed in it.

>
> Give it a try.  I'm no expert on HTML or XML syntax, there may be
> situations where it doesn't work well.  In that case suggest how it
> should work.
>
> --
> BLACK KNIGHT:  Come on you pansy!
>    [hah] [parry thrust]
>    [ARTHUR chops the BLACK KNIGHT's right arm off]
> ARTHUR:        Victory is mine!  [kneeling]
>               We thank thee Lord, that in thy merc-
>    [Black Knight kicks Arthur in the head while he is praying]
>                                  The Quest for the Holy Grail (Monty
> Python)
>
> /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
> ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ 
> \\\
> \\\              Project leader for A-A-P -- http://www.A-A-P.org 
> ///
> \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///


Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

Gautam Iyer
In reply to this post by Bram Moolenaar
On Wed, Jul 20, 2005 at 01:38:24PM +0200, Bram Moolenaar wrote:

> I have added a new feature in the snapshot uploaded last night: the
> "at" and "it" text objects.  The names stand for "A Tag" and "Inner
> Tag".

Super thanks. That's really helpfull!!

Just to add my 0.02$ though, I think it would be even more helpfull if
you could add the movement commands to work for tags!

To be more specific, something like:

1. [t and ]t to jump to the count outermost tag
2. a function to jump to the previous / next tag (i.e. treat each
   <a>junk</a> as a sentence, and jump between). I can't think of good
   bindings for it right now ...

I think this is partly implemented in matchit.vim. However if you
already have the code to select tags, these shouldn't be hard right?

Anywya, thanks for these functions :)

GI

--
Twenty Ways To Maintain A Healthy Level of Insanity
10. Ask people what sex they are. Laugh hysterically after they answer.
Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

James Vega-3
In reply to this post by A.J.Mechelynck
On Wed, Jul 20, 2005 at 02:37:54PM +0200, Tony Mechelynck wrote:

> In HTML, some tags (like META, BR, HR, ...) are always unpaired, others
> (like P, LI, ...) are optionally paired. I could scrap up a list if I
> weren't this lazy... well, on second thought it shouldn't be that hard:
>
> Always paired: A, ABBR, ACRONYM, ADDRESS, APPLET, B, BDO, BIG, BLINK,
> BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COLGROUP, COMMENT,
> DEL, DFN, DIR, DIV, DL, EM, FIELDSET, FONT, FORM, FRAMESET, H1, H2, H3, H4,
> H5, H6, HEAD, I, IFRAME, INS, KBD, LABEL, LAYER, LEGEND, LISTING, MAP,
> MARQUEE, MENU, MULTICOL, NOBR, NOFRAMES, NOSCRIPT, OBJECT, OL, OPTGROUP,
> PLAINTEXT, Q, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, STYLE,
> SUB, SUP, TABLE, TBODY, TEXTAREA, TFOOT, THEAD, TITLE, TT, U, UL, VAR, XMP
>
> Optionally paired: DD, DT, LI, P, TD, TH, TR
>
> Always unpaired: AREA, BASE, BASEFONT, BGSOUND, BR, COL, EMBED, FRAME, HR,
> HTML, IMG, INPUT, ISINDEX, LINK, META, OPTION, PARAM, SPACER, WBR
---^  This is definitely a paired tag.  A quick glance over the rest
seems correct.

James
--
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[hidden email]>

signature.asc (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

Craig Barkhouse
>On Wed, Jul 20, 2005 at 02:37:54PM +0200, Tony Mechelynck wrote:
>> In HTML, some tags (like META, BR, HR, ...) are always unpaired, others
>> (like P, LI, ...) are optionally paired. I could scrap up a list if I
>> weren't this lazy... well, on second thought it shouldn't be that hard:
>>
>> Always paired: A, ABBR, ACRONYM, ADDRESS, APPLET, B, BDO, BIG, BLINK,
>> BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COLGROUP, COMMENT,
>> DEL, DFN, DIR, DIV, DL, EM, FIELDSET, FONT, FORM, FRAMESET, H1, H2, H3,
>> H4,
>> H5, H6, HEAD, I, IFRAME, INS, KBD, LABEL, LAYER, LEGEND, LISTING, MAP,
>> MARQUEE, MENU, MULTICOL, NOBR, NOFRAMES, NOSCRIPT, OBJECT, OL, OPTGROUP,
>> PLAINTEXT, Q, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG,
>> STYLE,
>> SUB, SUP, TABLE, TBODY, TEXTAREA, TFOOT, THEAD, TITLE, TT, U, UL, VAR,
>> XMP
>>
>> Optionally paired: DD, DT, LI, P, TD, TH, TR
>>
>> Always unpaired: AREA, BASE, BASEFONT, BGSOUND, BR, COL, EMBED, FRAME,
>> HR,
>> HTML, IMG, INPUT, ISINDEX, LINK, META, OPTION, PARAM, SPACER, WBR
>---^  This is definitely a paired tag.  A quick glance over the rest
>seems correct.
>
>James

Well, you're both wrong.  ;)

Here's a better reference:  http://www.w3.org/TR/html4/index/elements.html

Just look at the "End Tag" column.  If it says (F)orbidden, then it's always
unpaired; if it says (O)ptional, then it's optionally paired.

Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

A.J.Mechelynck
In reply to this post by James Vega-3
----- Original Message -----
From: "James Vega" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, July 20, 2005 3:59 PM
Subject: Re: Selecting XML and HTML blocks

On Wed, Jul 20, 2005 at 02:37:54PM +0200, Tony Mechelynck wrote:

> In HTML, some tags (like META, BR, HR, ...) are always unpaired, others
> (like P, LI, ...) are optionally paired. I could scrap up a list if I
> weren't this lazy... well, on second thought it shouldn't be that hard:
>
> Always paired: A, ABBR, ACRONYM, ADDRESS, APPLET, B, BDO, BIG, BLINK,
> BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COLGROUP, COMMENT,
> DEL, DFN, DIR, DIV, DL, EM, FIELDSET, FONT, FORM, FRAMESET, H1, H2, H3,
> H4,
> H5, H6, HEAD, I, IFRAME, INS, KBD, LABEL, LAYER, LEGEND, LISTING, MAP,
> MARQUEE, MENU, MULTICOL, NOBR, NOFRAMES, NOSCRIPT, OBJECT, OL, OPTGROUP,
> PLAINTEXT, Q, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, STYLE,
> SUB, SUP, TABLE, TBODY, TEXTAREA, TFOOT, THEAD, TITLE, TT, U, UL, VAR, XMP
>
> Optionally paired: DD, DT, LI, P, TD, TH, TR
>
> Always unpaired: AREA, BASE, BASEFONT, BGSOUND, BR, COL, EMBED, FRAME, HR,
> HTML, IMG, INPUT, ISINDEX, LINK, META, OPTION, PARAM, SPACER, WBR
---^  This is definitely a paired tag.  A quick glance over the rest
seems correct.

James

Oops... you're right: HTML is paired. My bad.

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

A.J.Mechelynck
In reply to this post by Craig Barkhouse
----- Original Message -----
From: "Craig Barkhouse" <[hidden email]>
To: "VIM Developers" <[hidden email]>
Sent: Wednesday, July 20, 2005 4:16 PM
Subject: Re: Selecting XML and HTML blocks


> >On Wed, Jul 20, 2005 at 02:37:54PM +0200, Tony Mechelynck wrote:
>>> In HTML, some tags (like META, BR, HR, ...) are always unpaired, others
>>> (like P, LI, ...) are optionally paired. I could scrap up a list if I
>>> weren't this lazy... well, on second thought it shouldn't be that hard:
>>>
>>> Always paired: A, ABBR, ACRONYM, ADDRESS, APPLET, B, BDO, BIG, BLINK,
>>> BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COLGROUP,
>>> COMMENT,
>>> DEL, DFN, DIR, DIV, DL, EM, FIELDSET, FONT, FORM, FRAMESET, H1, H2, H3,
>>> H4,
>>> H5, H6, HEAD, I, IFRAME, INS, KBD, LABEL, LAYER, LEGEND, LISTING, MAP,
>>> MARQUEE, MENU, MULTICOL, NOBR, NOFRAMES, NOSCRIPT, OBJECT, OL, OPTGROUP,
>>> PLAINTEXT, Q, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG,
>>> STYLE,
>>> SUB, SUP, TABLE, TBODY, TEXTAREA, TFOOT, THEAD, TITLE, TT, U, UL, VAR,
>>> XMP
>>>
>>> Optionally paired: DD, DT, LI, P, TD, TH, TR
>>>
>>> Always unpaired: AREA, BASE, BASEFONT, BGSOUND, BR, COL, EMBED, FRAME,
>>> HR,
>>> HTML, IMG, INPUT, ISINDEX, LINK, META, OPTION, PARAM, SPACER, WBR
>>---^  This is definitely a paired tag.  A quick glance over the rest
>>seems correct.
>>
>>James
>
> Well, you're both wrong.  ;)
>
> Here's a better reference:  http://www.w3.org/TR/html4/index/elements.html
>
> Just look at the "End Tag" column.  If it says (F)orbidden, then it's
> always unpaired; if it says (O)ptional, then it's optionally paired.

More official, yes. Better, that depends on point of view. It does not list
some "unofficial" tags which have been used, are recognised by some
widespread browsers, and should IMHO be properly handled by Vim.

-- BTW, I didn't know that HEAD and BODY (and TBODY) not only were
optionally paired, but also could lack an _opening_ tag. Does that mean that
a structure like

<HTML>
    <META>
    <TITLE>...</TITLE>
    <STYLE>
        <!--
            ...stylesheet...
        // -->
    </STYLE>
    <H1>...</H1>
    ...text...
    <DIV>...</DIV>
    etc.
</HTML>

(where the attributes of the tags have been omitted for the sake of clarity)
is valid HTML? Could </HEAD> and/or </BODY> be present without the
corresponding opening tag? All textbooks I've seen on the subject said that
both <HEAD> and <BODY> had to be present and paired, and that most elements
could go into one or the other part but not both. Well, one learns every
day.


Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

Craig Barkhouse

----- Original Message -----
From: "Tony Mechelynck" <[hidden email]>
To: "Craig Barkhouse" <[hidden email]>; "VIM Developers"
<[hidden email]>
Sent: Wednesday, July 20, 2005 11:02 AM
Subject: Re: Selecting XML and HTML blocks

> More official, yes. Better, that depends on point of view. It does not
> list some "unofficial" tags which have been used, are recognised by some
> widespread browsers, and should IMHO be properly handled by Vim.

Yes, I just mean "better" for official tags.  I agree that Vim should
support popular unofficial tags too.

> Could </HEAD> and/or </BODY> be present without the corresponding opening
> tag?

No, you definitely need a start tag before you can have a corresponding end
tag.  Of course, web browsers likely just ignore stray end tags, as they are
intended to be as tolerant as possible.  Ideally, Vim would highlight stray
end tags as errors.

Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

Bram Moolenaar
In reply to this post by Gautam Iyer

Gautam wrote:

> On Wed, Jul 20, 2005 at 01:38:24PM +0200, Bram Moolenaar wrote:
>
> > I have added a new feature in the snapshot uploaded last night: the
> > "at" and "it" text objects.  The names stand for "A Tag" and "Inner
> > Tag".
>
> Super thanks. That's really helpfull!!
>
> Just to add my 0.02$ though, I think it would be even more helpfull if
> you could add the movement commands to work for tags!
>
> To be more specific, something like:
>
> 1. [t and ]t to jump to the count outermost tag

Is this what "vatov" and "vatv" do?

> 2. a function to jump to the previous / next tag (i.e. treat each
>    <a>junk</a> as a sentence, and jump between). I can't think of good
>    bindings for it right now ...

I don't quite understand how this would work.

> I think this is partly implemented in matchit.vim. However if you
> already have the code to select tags, these shouldn't be hard right?

With matchit you can jump from <a> to the matching </a> and back, but
not to a previous <a>.

--
FATHER:    You only killed the bride's father - that's all -
LAUNCELOT: Oh dear, I didn't really mean to...
FATHER:    Didn't mean to?  You put your sword right through his head!
LAUNCELOT: Gosh - Is he all right?
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

Bram Moolenaar
In reply to this post by A.J.Mechelynck

Tony Mechelynck wrote:

> > I have added a new feature in the snapshot uploaded last night: the "at"
> > and "it" text objects.  The names stand for "A Tag" and "Inner Tag".

[...]

> The recent tendency in HTML is XHTML, i.e., documents which can be treated
> as either HTML or XML depending on circumstances. The difference with
> "classical" HTML is that unpaired tags have a / just before the closing >.
> (In XML, all tags must be paired unless that slash is present.)
>
> In HTML, some tags (like META, BR, HR, ...) are always unpaired, others
> (like P, LI, ...) are optionally paired. I could scrap up a list if I
> weren't this lazy... well, on second thought it shouldn't be that hard:

The code doesn't look at the name of the tag, it just tries finding the
matching end tag.  I would prefer to keep it that way, since the list is
never complete.

You don't mention that there is a problem with a certain HTML file, thus
I don't see a reason to add checking the tag name.

--
   [SIR LAUNCELOT runs back up the stairs, grabs a rope
   of the wall and swings out over the heads of the CROWD in a
   swashbuckling manner towards a large window.  He stops just short
   of the window and is left swing pathetically back and forth.]
LAUNCELOT: Excuse me ... could somebody give me a push ...
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

Gautam Iyer
In reply to this post by Bram Moolenaar
On Wed, Jul 20, 2005 at 10:51:14PM +0200, Bram Moolenaar wrote:

> Gautam wrote:
>
> > On Wed, Jul 20, 2005 at 01:38:24PM +0200, Bram Moolenaar wrote:
> >
> > > I have added a new feature in the snapshot uploaded last night: the
> > > "at" and "it" text objects.  The names stand for "A Tag" and "Inner
> > > Tag".
> >
> > Super thanks. That's really helpfull!!
> >
> > Just to add my 0.02$ though, I think it would be even more helpfull if
> > you could add the movement commands to work for tags!
> >
> > To be more specific, something like:
> >
> > 1. [t and ]t to jump to the count outermost tag
>
> Is this what "vatov" and "vatv" do?

Hey. That's clever. Yes defenately. However "vatv" and "vatov" don't
accept a count. If I bound the above to a key then maybe it'll work as I
want with a count. If not a two line script should solve the problem.

Just wondering if you / others think it's usefull enough to include by
default.

> > 2. a function to jump to the previous / next tag (i.e. treat each
> >    <a>junk</a> as a sentence, and jump between). I can't think of good
> >    bindings for it right now ...
>
> I don't quite understand how this would work.

For example your file contains

<a>stuff<b>more stuff</b></a> other stuff <c>cursor X here</c>

Assume the cursor is on the X. The first backward jump should put the
cursor on the <c> tag. The second backward jump should put the cursor on
the <a> tag. I.e. work exactly like ( and ) but for tags instead.

The example use I had in mind was for instance when creating an ordered
list. Your text between each <li> .. </li> contains some markup. Only
jumping to outermost tags will take you from the current list item
you're editing to the <ol> tag. But not to the previous or next <li>
tag.

Same goes for multiple paragraphs. I generally seperate paragraphs with
new lines and use { and }, but I'm sure there are other uses of this
kind of movement :).

> > I think this is partly implemented in matchit.vim. However if you
> > already have the code to select tags, these shouldn't be hard right?
>
> With matchit you can jump from <a> to the matching </a> and back, but
> not to a previous <a>.

Yep.

GI


--
'Common' Proof Techniques:
18. Proof by importance -- A large body of useful consequences all
follow from the proposition in question.
Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

Gautam Iyer
In reply to this post by Bram Moolenaar
On Wed, Jul 20, 2005 at 10:51:14PM +0200, Bram Moolenaar wrote:

> The code doesn't look at the name of the tag, it just tries finding the
> matching end tag.  I would prefer to keep it that way, since the list is
> never complete.
>
> You don't mention that there is a problem with a certain HTML file,
> thus I don't see a reason to add checking the tag name.

If you decide to look at the name of the tag, maybe you can have vim
options listing the names of unmatched / optional tags? Thus as the list
grows bigger, only the ftplugin needs to be changed.

:)

GI

--
'Boat' -- A hole in the water surrounded by wood into which one pours
money.
Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

Mikołaj Machowski
In reply to this post by Bram Moolenaar
Dnia ?roda 20 lipiec 2005 13:38, Bram Moolenaar napisa?:
> I have added a new feature in the snapshot uploaded last night: the "at"
> and "it" text objects.  The names stand for "A Tag" and "Inner Tag".
>
> These text objects are most useful when editing HTML, SGML and XML
> files.  When the cursor is in a start tag, say <b>, then "vat" will
> select the text up to and including the matching </b>.  "vat" als works
> when the cursor is in the text or on the </b>.

Amazing. Great, great thing.

> XML tags in the form <aaa/> are ignored, since they don't come in
> pairs.  

That is drawback. <aaa /> style tags can be PITA for selecting.  Even in
relatively simple XHTML <img/> and <meta/> tags can be multi-line, not
mentioning heavier XML dialects.

IMO it and at should work here without differences - if called on empty tag
(<aaxa /> - with x a cursor) it should select whole tag.

> For HTML there are also non-paired tags, but this is not
> obvious.  They are ignored if a matching tag can't be found.

HTML is slowly passing away and XHTML (XMLized HTML) require pairing of
tags or closing them in <aaa /> style.

m.

--
LaTeX + Vim = http://vim-latex.sourceforge.net/
Vim-list(s) Users Map: (last change 15 May)
 http://skawina.eu.org/mikolaj/vimlist
CLEWN - http://clewn.sf.net

Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

Bram Moolenaar

Mikolaj Machowski wrote:

> Dnia ?roda 20 lipiec 2005 13:38, Bram Moolenaar napisa?:
> > I have added a new feature in the snapshot uploaded last night: the "at"
> > and "it" text objects.  The names stand for "A Tag" and "Inner Tag".
> >
> > These text objects are most useful when editing HTML, SGML and XML
> > files.  When the cursor is in a start tag, say <b>, then "vat" will
> > select the text up to and including the matching </b>.  "vat" als works
> > when the cursor is in the text or on the </b>.
>
> Amazing. Great, great thing.
>
> > XML tags in the form <aaa/> are ignored, since they don't come in
> > pairs.  
>
> That is drawback. <aaa /> style tags can be PITA for selecting.  Even in
> relatively simple XHTML <img/> and <meta/> tags can be multi-line, not
> mentioning heavier XML dialects.
>
> IMO it and at should work here without differences - if called on empty tag
> (<aaxa /> - with x a cursor) it should select whole tag.

You can use the "a>" text object for that.

> > For HTML there are also non-paired tags, but this is not
> > obvious.  They are ignored if a matching tag can't be found.
>
> HTML is slowly passing away and XHTML (XMLized HTML) require pairing of
> tags or closing them in <aaa /> style.

HTML wasn't very clean, but it's still the most widely supported method
for web pages.

--
Dogs must have a permit signed by the mayor in order to congregate in groups
of three or more on private property.
                [real standing law in Oklahoma, United States of America]

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: Selecting XML and HTML blocks

Mikołaj Machowski
Dnia wtorek 26 lipiec 2005 11:40, Bram Moolenaar napisa?:
> > IMO it and at should work here without differences - if called on
> > empty tag (<aaxa /> - with x a cursor) it should select whole tag.
>
> You can use the "a>" text object for that.

Sorry, didn't know about that.

m.