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

Re: How to check if I have lines with different length in a database extract

Expand Messages
  • Bertilo Wennergren
    ... That actually seems to count bytes, not characters. I tried it using UTF-8, and my two-byte characters counted as two, at least sometimes. The results were
    Message 1 of 9 , Nov 2, 2005
    • 0 Attachment
      On 11/2/05, Tim Chase <vim@...> wrote:

      > If, however, you've got a large file (or more lines than you
      > reasonably care to scroll through), you can use something like

      > :v/\%40c.$/#
      >
      > which will return a list of each of the lines that *don't* have 40
      > characters in them,

      That actually seems to count bytes, not characters. I tried it using
      UTF-8, and my two-byte characters counted as two, at least sometimes.
      The results were not consistent!

      E.g.:

      oooo
      oooö
      oooo

      :v/\%4c.$/#
      Pattern found in every line: \%4c.$

      But:

      oooo
      ooöo
      oooo

      :v/\%4c.$/#
      2 ooöo

      Have I stumbled on a bug? This was in Vim 6.4 in Linux (Kubuntu).

      --
      Bertilo Wennergren <http://bertilow.com>
    • Tim Chase
      ... How strange. Bug? perhaps, or fixable with some option-obscura. I can t be of much help here as I don t use UTF-8 or multi-byte character sets/encodings
      Message 2 of 9 , Nov 2, 2005
      • 0 Attachment
        > That actually seems to count bytes, not characters. I
        > tried it using UTF-8, and my two-byte characters counted
        > as two, at least sometimes. The results were not
        > consistent!
        >
        > E.g.:
        >
        > oooo
        > oooö
        > oooo
        >
        > :v/\%4c.$/#
        > Pattern found in every line: \%4c.$
        >
        > But:
        >
        > oooo
        > ooöo
        > oooo
        >
        > :v/\%4c.$/#
        > 2 ooöo
        >
        > Have I stumbled on a bug? This was in Vim 6.4 in Linux
        > (Kubuntu).

        How strange. Bug? perhaps, or fixable with some
        option-obscura. I can't be of much help here as I don't use
        UTF-8 or multi-byte character sets/encodings for
        anything...other than occasionally trying out some of the
        crazy-good ideas by folks like Tony on the list who are much
        more well-versed in the ins and outs of this dark corner of
        Vim.

        -tim
      • James Vega
        ... Use %4v instead of %4c. ... James -- GPG Key: 1024D/61326D40 2003-09-02 James Vega
        Message 3 of 9 , Nov 2, 2005
        • 0 Attachment
          On Wed, Nov 02, 2005 at 10:36:33PM +0900, Bertilo Wennergren wrote:
          > On 11/2/05, Tim Chase <vim@...> wrote:
          >
          > > If, however, you've got a large file (or more lines than you
          > > reasonably care to scroll through), you can use something like
          >
          > > :v/\%40c.$/#
          > >
          > > which will return a list of each of the lines that *don't* have 40
          > > characters in them,
          >
          > That actually seems to count bytes, not characters. I tried it using
          > UTF-8, and my two-byte characters counted as two, at least sometimes.
          > The results were not consistent!
          >
          > E.g.:
          >
          > oooo
          > oooö
          > oooo
          >
          > :v/\%4c.$/#
          > Pattern found in every line: \%4c.$
          >
          > But:
          >
          > oooo
          > ooöo
          > oooo
          >
          > :v/\%4c.$/#
          > 2 ooöo
          >
          > Have I stumbled on a bug? This was in Vim 6.4 in Linux (Kubuntu).

          Use \%4v instead of \%4c.

          :he /\%c
          :he /\%v

          James
          --
          GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan@...>
        • Charles E. Campbell, Jr.
          ... will display all lines that don t have 74 characters in them. I just picked 74 out of the air, of course -- adjust it to whatever you need. Regards, Chip
          Message 4 of 9 , Nov 2, 2005
          • 0 Attachment
            sanjeev.g.sapre@... wrote:

            >...Each type of file has some fixed length of a line. Before we can pass on
            >this file for further processing I would like to check that all lines are
            >of equal length. Is there a simple way /pattern by which I can identify
            >lines with differing length.
            >
            >
            :v/^.*\%74c.$/p

            will display all lines that don't have 74 characters in them. I just
            picked 74 out of the air, of course -- adjust it to whatever you need.

            Regards,
            Chip Campbell
          Your message has been successfully submitted and would be delivered to recipients shortly.