Loading ...
Sorry, an error occurred while loading the content.

RE: (idea for a patch) Sentences, paragraphs

Expand Messages
  • Benjamin Peterson
    Hi, Just thinking about sentences and paragraphs... ... Hmm, okay, how about this html: This is a sentence. This is one in italics. This is a third
    Message 1 of 9 , Aug 21, 2003

      Just thinking about sentences and paragraphs...

      >> 2 -- The definition of a sentence is suitable for plain text but not
      >> very useful for html
      >That doesn't look like a sentence to me. I would call it a line or a

      Hmm, okay, how about this html:

      This is a sentence. <i>This is one in italics.</i> This is a third
      <li>Here's a sentence. Here's another one.</li>

      Some sentences here will not be recognized as such because there's no
      space after the '.' -- but in HTML a '.' is often followed by a tag, not
      by spaces. Perhaps the rule could be (in regex form) \w\.\W

      That would also recognize 'Exclamations!?' and 'Ellipses...', which I
      tend to think would be a good thing.

      >> A -- expand the range of characters that can end a sentence to
      >> Japanese (and other) punctuation.

      >A generic solution would be useful.

      Allow the user to specify a list of such characters in an option? Or
      just hardcode the set of characters that Unicode considers to be
      sentence delimiters? I think I'd favor the latter because having
      useful, fast hard-coded behavior is a strong point of vim. Then allow a
      regex if the user needs the definition of 'sentence' to be really

      >> C -- have two options, for paragraph and section, each containing a
      >> regex.

      >Useful, but can be a bit slow. Would have to check every character
      >position if the regexp matches.

      The user would usually want something like /^\t\w* or /^\s*$, which
      should be fairly fast. If they give a difficult regex that doesn't
      start with '^', that's their choice.

      >> D -- just maybe have an option for sentence searches.

      >Sounds like almost the same thing as (C). You can use "\zs" to set the
      >cursor position.

      I wasn't aware of \zs when I wrote that. There's always one more
      feature in vim. I guess \zs would allow you to exactly duplicate the
      current behaviour, even when the sentence ends the line.

      >> E -- just maybe, depending on feasibility, have syntax highlighting
      >> sections in the same way it adds folds now. This is just an idle
      >> thought, I doubt I could implement it.

      >A more generic way would be to use a regexp to find a section and allow
      >using syntax elements in the regexp. This can be very slow though.

      Yes, that would be the right way to do it...

    Your message has been successfully submitted and would be delivered to recipients shortly.