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

Re: Syntax Matching ASCII Values

Expand Messages
  • Nowhere Man
    ... Thats the first thing I tried... vim matches x to a hex digit ... so: -- in vim: this is test A20 / x20 {this should match all spaces..} this will only
    Message 1 of 6 , Jul 5 3:06 PM
    • 0 Attachment
      On Mon, 5 Jul 2004 08:59:10 -0400, Benji Fisher <benji@...> wrote:
      > On Sat, Jul 03, 2004 at 02:43:40AM -0500, Nowhere Man wrote:
      > > Is it possible to match a range of characters based upon their ASCII value?
      > >
      > > Such as:
      > >
      > > syn range HiBit /\x80-\xFF/
      >
      > I have not tried it myself, but it should be possible. See
      >
      > :help /\[
      >
      > You may have to enter the characters literally, in which case :execute
      > may help, as in (untested)
      >
      > :execute "syn range HiBit /[\x80-\xFF]/"


      Thats the first thing I tried... vim matches \x to a "hex digit"... so:

      -- in vim:
      this is test A20

      /\x20 {this should match all spaces..}

      this will only match "A20"

      (syn range isn't correct)
      :syn match Error /[\x80-\xFF]/

      doesn't seem to match anything

      :syn match Error /\x20/
      has the same behavior as the search.


      --

      . o O pyromancer O o .
    • Benji Fisher
      ... Did you try what I suggested? I put the x inside a string , so that it gets converted to the specified ASCII character. ... I do not think that / x20
      Message 2 of 6 , Jul 5 8:28 PM
      • 0 Attachment
        On Mon, Jul 05, 2004 at 05:06:35PM -0500, Nowhere Man wrote:
        > On Mon, 5 Jul 2004 08:59:10 -0400, Benji Fisher <benji@...> wrote:
        > > On Sat, Jul 03, 2004 at 02:43:40AM -0500, Nowhere Man wrote:
        > > > Is it possible to match a range of characters based upon their ASCII value?
        > > >
        > > > Such as:
        > > >
        > > > syn range HiBit /\x80-\xFF/
        > >
        > > I have not tried it myself, but it should be possible. See
        > >
        > > :help /\[
        > >
        > > You may have to enter the characters literally, in which case :execute
        > > may help, as in (untested)
        > >
        > > :execute "syn range HiBit /[\x80-\xFF]/"
        >
        >
        > Thats the first thing I tried... vim matches \x to a "hex digit"... so:
        >
        > -- in vim:
        > this is test A20
        >
        > /\x20 {this should match all spaces..}
        >
        > this will only match "A20"
        >
        > (syn range isn't correct)
        > :syn match Error /[\x80-\xFF]/
        >
        > doesn't seem to match anything
        >
        > :syn match Error /\x20/
        > has the same behavior as the search.

        Did you try what I suggested? I put the \x inside a "string", so
        that it gets converted to the specified ASCII character.

        :help :execute
        :help expr-string

        I do not think that

        /\x20

        should match all spaces, but I did test

        :execute "/\x20"

        and it seems to work.

        HTH --Benji Fisher
      • David Rayner
        ... Hi, Sorry haven t caught the whole of this thread, but here s my pennyworth / Decimal value of character eg / 65 finds A /[ 128- 255]
        Message 3 of 6 , Jul 6 4:18 AM
        • 0 Attachment
          > Is it possible to match a range of characters based upon their ASCII value?
          >
          > Such as:
          >
          > syn range HiBit /\x80-\xFF/
          >
          Hi,
          Sorry haven't caught the whole of this thread, but here's my pennyworth

          /<C-V>Decimal value of character

          eg
          /<C-V>65 finds "A"

          /[<C-V>128-<C-V>255] # catch all top bit set

          /[<C-V>01-<C-V>31] #catch all less than "1"

          /[€-ÿ^A-^_] # catch all pesky non-ascii


          Windows users probably use <C-Q> not <C-V>

          --
          zzapper (vim,cygwin,wiki & zsh)

          vim -c ":%s.^.CyrnfrTfcbafbeROenzSZbbyranne.|:%s/[R-T]/ /Ig|:normal ggVGg?"

          http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips
        • Nowhere Man
          ah ha! Thank you! I did not see the significance of the quotes before. Now I do... and help expr-string is the key... Thank you once again! ... -- . o O
          Message 4 of 6 , Jul 6 4:45 AM
          • 0 Attachment
            ah ha! Thank you! I did not see the significance of the quotes
            before. Now I do... and "help expr-string" is the key...

            Thank you once again!


            On Mon, 5 Jul 2004 23:28:44 -0400, Benji Fisher <benji@...> wrote:
            >
            >
            > On Mon, Jul 05, 2004 at 05:06:35PM -0500, Nowhere Man wrote:
            > > On Mon, 5 Jul 2004 08:59:10 -0400, Benji Fisher <benji@...> wrote:
            > > > On Sat, Jul 03, 2004 at 02:43:40AM -0500, Nowhere Man wrote:
            > > > > Is it possible to match a range of characters based upon their ASCII value?
            > > > >
            > > > > Such as:
            > > > >
            > > > > syn range HiBit /\x80-\xFF/
            > > >
            > > > I have not tried it myself, but it should be possible. See
            > > >
            > > > :help /\[
            > > >
            > > > You may have to enter the characters literally, in which case :execute
            > > > may help, as in (untested)
            > > >
            > > > :execute "syn range HiBit /[\x80-\xFF]/"
            > >
            > >
            > > Thats the first thing I tried... vim matches \x to a "hex digit"... so:
            > >
            > > -- in vim:
            > > this is test A20
            > >
            > > /\x20 {this should match all spaces..}
            > >
            > > this will only match "A20"
            > >
            > > (syn range isn't correct)
            > > :syn match Error /[\x80-\xFF]/
            > >
            > > doesn't seem to match anything
            > >
            > > :syn match Error /\x20/
            > > has the same behavior as the search.
            >
            > Did you try what I suggested? I put the \x inside a "string", so
            > that it gets converted to the specified ASCII character.
            >
            > :help :execute
            > :help expr-string
            >
            > I do not think that
            >
            > /\x20
            >
            > should match all spaces, but I did test
            >
            > :execute "/\x20"
            >
            > and it seems to work.
            >
            > HTH --Benji Fisher
            >


            --

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