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

'isfname' and 'isprint' don't allow to include ^@ = 0

Expand Messages
  • Ingo Karkat
    Hello Vim developers, a question on Super User (http://superuser.com/questions/766817/hide-non-printable-characters-in-vim/) asks to show all non-printable
    Message 1 of 5 , Jun 10, 2014
      Hello Vim developers,

      a question on Super User
      (http://superuser.com/questions/766817/hide-non-printable-characters-in-vim/)
      asks to show all non-printable (control) characters with a single
      display cell. One (hacky, and arguably not perfect) way to do this is by
      including all ASCII characters in 'isprint':

      :set isprint=0-255

      However, this yields "E474: Invalid argument". It only works by
      excluding ^@ = 0 (via :set isprint=1-255). Also, other variants such as
      :set isprint^=0 and :set isprint=0,1-255 and :set
      isprint=<C-v><C-@>,1-255 do not work (verified up to current version
      7.4.316).

      The same applies to the similar 'isfname' setting, even though its
      documentation (and 'isprint' refers to that, too) explicitly mentions
      the number 0:

      ,----[ :help 'isfname' excerpt ]----
      | The format of this option is a list of parts, separated with commas.
      | Each part can be a single character number or a range. A range is two
      | character numbers with '-' in between. A character number can be a
      | decimal number between 0 and 255 or the ASCII character itself (does
      | not work for digits).
      `----

      I see this as a bug in the :set command, or, if technical reasons
      prevent the use of ^@ in those option values, a bug in the
      documentation. (Preferably, to address the issue in the mentioned
      question, the first. :-)

      -- regards, ingo

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Christian Brabandt
      ... I don t know if it is a bug or it was done intentionally and I even don t know what :set isprint=0-255 is supposed to be doing. But here is a patch: diff
      Message 2 of 5 , Jun 11, 2014
        On Di, 10 Jun 2014, Ingo Karkat wrote:

        > Hello Vim developers,
        >
        > a question on Super User
        > (http://superuser.com/questions/766817/hide-non-printable-characters-in-vim/)
        > asks to show all non-printable (control) characters with a single
        > display cell. One (hacky, and arguably not perfect) way to do this is by
        > including all ASCII characters in 'isprint':
        >
        > :set isprint=0-255
        >
        > However, this yields "E474: Invalid argument". It only works by
        > excluding ^@ = 0 (via :set isprint=1-255). Also, other variants such as
        > :set isprint^=0 and :set isprint=0,1-255 and :set
        > isprint=<C-v><C-@>,1-255 do not work (verified up to current version
        > 7.4.316).
        >
        > The same applies to the similar 'isfname' setting, even though its
        > documentation (and 'isprint' refers to that, too) explicitly mentions
        > the number 0:
        >
        > ,----[ :help 'isfname' excerpt ]----
        > | The format of this option is a list of parts, separated with commas.
        > | Each part can be a single character number or a range. A range is two
        > | character numbers with '-' in between. A character number can be a
        > | decimal number between 0 and 255 or the ASCII character itself (does
        > | not work for digits).
        > `----
        >
        > I see this as a bug in the :set command, or, if technical reasons
        > prevent the use of ^@ in those option values, a bug in the
        > documentation. (Preferably, to address the issue in the mentioned
        > question, the first. :-)

        I don't know if it is a bug or it was done intentionally and I even
        don't know what :set isprint=0-255 is supposed to be doing. But here is
        a patch:

        diff --git a/src/charset.c b/src/charset.c
        --- a/src/charset.c
        +++ b/src/charset.c
        @@ -197,7 +197,7 @@ buf_init_chartab(buf, global)
        #endif
        c2 = *p++;
        }
        - if (c <= 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256
        + if (c < 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256
        || !(*p == NUL || *p == ','))
        return FAIL;



        Mit freundlichen Grüßen
        Christian
        --
        Ich erziehe Kinder nicht zu etwas, sondern in etwas.
        -- Jean Paul

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Bram Moolenaar
        ... Well, this allows having a zero in the option value, but I very much doubt it actually works. In C the zero is used to terminate a string, thus sending a
        Message 3 of 5 , Jun 12, 2014
          Christian wrote:

          > On Di, 10 Jun 2014, Ingo Karkat wrote:
          >
          > > Hello Vim developers,
          > >
          > > a question on Super User
          > > (http://superuser.com/questions/766817/hide-non-printable-characters-in-vim/)
          > > asks to show all non-printable (control) characters with a single
          > > display cell. One (hacky, and arguably not perfect) way to do this is by
          > > including all ASCII characters in 'isprint':
          > >
          > > :set isprint=0-255
          > >
          > > However, this yields "E474: Invalid argument". It only works by
          > > excluding ^@ = 0 (via :set isprint=1-255). Also, other variants such as
          > > :set isprint^=0 and :set isprint=0,1-255 and :set
          > > isprint=<C-v><C-@>,1-255 do not work (verified up to current version
          > > 7.4.316).
          > >
          > > The same applies to the similar 'isfname' setting, even though its
          > > documentation (and 'isprint' refers to that, too) explicitly mentions
          > > the number 0:
          > >
          > > ,----[ :help 'isfname' excerpt ]----
          > > | The format of this option is a list of parts, separated with commas.
          > > | Each part can be a single character number or a range. A range is two
          > > | character numbers with '-' in between. A character number can be a
          > > | decimal number between 0 and 255 or the ASCII character itself (does
          > > | not work for digits).
          > > `----
          > >
          > > I see this as a bug in the :set command, or, if technical reasons
          > > prevent the use of ^@ in those option values, a bug in the
          > > documentation. (Preferably, to address the issue in the mentioned
          > > question, the first. :-)
          >
          > I don't know if it is a bug or it was done intentionally and I even
          > don't know what :set isprint=0-255 is supposed to be doing. But here is
          > a patch:
          >
          > diff --git a/src/charset.c b/src/charset.c
          > --- a/src/charset.c
          > +++ b/src/charset.c
          > @@ -197,7 +197,7 @@ buf_init_chartab(buf, global)
          > #endif
          > c2 = *p++;
          > }
          > - if (c <= 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256
          > + if (c < 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256
          > || !(*p == NUL || *p == ','))
          > return FAIL;

          Well, this allows having a zero in the option value, but I very much
          doubt it actually works. In C the zero is used to terminate a string,
          thus sending a zero to the terminal just won't work.

          If you want to *display* control characters you need to do something
          else anyway, since sending a BS or other control character won't result
          in displaying anything.

          --
          The greatest lies of all time:
          (1) The check is in the mail.
          (2) We have a really challenging assignment for you.
          (3) I love you.
          (4) All bugs have been fixed.
          (5) This won't hurt a bit.
          (6) Honey, I just need to debug this program and be home in 5 minutes.
          (7) I have just sent you an e-mail about that.
          (8) Of course I'll respect you in the morning.
          (9) I'm from the government, and I'm here to help you.

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ an exciting new programming language -- http://www.Zimbu.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          --
          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Ingo Karkat
          ... Well, at least I can do this in a terminal: $ printf foo 0bar n foobar Seems like Bash handles this somehow, and the NUL is skipped / prints as nothing.
          Message 4 of 5 , Jun 12, 2014
            On 12-Jun-2014 12:51 +0200, Bram Moolenaar wrote:

            > Christian wrote:
            >
            >> On Di, 10 Jun 2014, Ingo Karkat wrote:
            >>
            >>> Hello Vim developers,
            >>>
            >>> a question on Super User
            >>> (http://superuser.com/questions/766817/hide-non-printable-characters-in-vim/)
            >>> asks to show all non-printable (control) characters with a single
            >>> display cell. One (hacky, and arguably not perfect) way to do this is by
            >>> including all ASCII characters in 'isprint':
            >>>
            >>> :set isprint=0-255
            >>>
            >>> However, this yields "E474: Invalid argument". It only works by
            >>> excluding ^@ = 0 (via :set isprint=1-255). Also, other variants such as
            >>> :set isprint^=0 and :set isprint=0,1-255 and :set
            >>> isprint=<C-v><C-@>,1-255 do not work (verified up to current version
            >>> 7.4.316).
            >>>
            >>> The same applies to the similar 'isfname' setting, even though its
            >>> documentation (and 'isprint' refers to that, too) explicitly mentions
            >>> the number 0:
            >>>
            >>> ,----[ :help 'isfname' excerpt ]----
            >>> | The format of this option is a list of parts, separated with commas.
            >>> | Each part can be a single character number or a range. A range is two
            >>> | character numbers with '-' in between. A character number can be a
            >>> | decimal number between 0 and 255 or the ASCII character itself (does
            >>> | not work for digits).
            >>> `----
            >>>
            >>> I see this as a bug in the :set command, or, if technical reasons
            >>> prevent the use of ^@ in those option values, a bug in the
            >>> documentation. (Preferably, to address the issue in the mentioned
            >>> question, the first. :-)
            >>
            >> I don't know if it is a bug or it was done intentionally and I even
            >> don't know what :set isprint=0-255 is supposed to be doing. But here is
            >> a patch:
            >>
            >> diff --git a/src/charset.c b/src/charset.c
            >> --- a/src/charset.c
            >> +++ b/src/charset.c
            >> @@ -197,7 +197,7 @@ buf_init_chartab(buf, global)
            >> #endif
            >> c2 = *p++;
            >> }
            >> - if (c <= 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256
            >> + if (c < 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256
            >> || !(*p == NUL || *p == ','))
            >> return FAIL;
            >
            > Well, this allows having a zero in the option value, but I very much
            > doubt it actually works. In C the zero is used to terminate a string,
            > thus sending a zero to the terminal just won't work.

            Well, at least I can do this in a terminal:

            $ printf "foo\0bar\n"
            foobar

            Seems like Bash handles this somehow, and the NUL is skipped / prints as
            nothing.

            > If you want to *display* control characters you need to do something
            > else anyway, since sending a BS or other control character won't result
            > in displaying anything.

            The OP's use case is representing every character by a single display
            cell. Obviously, BS will mess up things. But probably, a (binary) file
            won't contain many of those (in the area of interest), but possibly a
            lot of NULs. Skipping those in the output might be okay for his use.

            -- regards, ingo

            --
            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          • Ingo Karkat
            ... I ve just tested Christian s patch (on Ubuntu 13.10); adding 0 to isprint messes up the displayed window contents in terminal Vim, less so in GVIM
            Message 5 of 5 , Jun 30, 2014
              On 12-Jun-2014 13:07 +0200, Ingo Karkat wrote:

              > On 12-Jun-2014 12:51 +0200, Bram Moolenaar wrote:
              >
              >> Christian wrote:
              >>
              >>> On Di, 10 Jun 2014, Ingo Karkat wrote:
              >>>
              >>>> Hello Vim developers,
              >>>>
              >>>> a question on Super User
              >>>> (http://superuser.com/questions/766817/hide-non-printable-characters-in-vim/)
              >>>> asks to show all non-printable (control) characters with a single
              >>>> display cell. One (hacky, and arguably not perfect) way to do this is by
              >>>> including all ASCII characters in 'isprint':
              >>>>
              >>>> :set isprint=0-255
              >>>>
              >>>> However, this yields "E474: Invalid argument". It only works by
              >>>> excluding ^@ = 0 (via :set isprint=1-255). Also, other variants such as
              >>>> :set isprint^=0 and :set isprint=0,1-255 and :set
              >>>> isprint=<C-v><C-@>,1-255 do not work (verified up to current version
              >>>> 7.4.316).
              >>>>
              >>>> The same applies to the similar 'isfname' setting, even though its
              >>>> documentation (and 'isprint' refers to that, too) explicitly mentions
              >>>> the number 0:
              >>>>
              >>>> ,----[ :help 'isfname' excerpt ]----
              >>>> | The format of this option is a list of parts, separated with commas.
              >>>> | Each part can be a single character number or a range. A range is two
              >>>> | character numbers with '-' in between. A character number can be a
              >>>> | decimal number between 0 and 255 or the ASCII character itself (does
              >>>> | not work for digits).
              >>>> `----
              >>>>
              >>>> I see this as a bug in the :set command, or, if technical reasons
              >>>> prevent the use of ^@ in those option values, a bug in the
              >>>> documentation. (Preferably, to address the issue in the mentioned
              >>>> question, the first. :-)
              >>>
              >>> I don't know if it is a bug or it was done intentionally and I even
              >>> don't know what :set isprint=0-255 is supposed to be doing. But here is
              >>> a patch:
              >>>
              >>> diff --git a/src/charset.c b/src/charset.c
              >>> --- a/src/charset.c
              >>> +++ b/src/charset.c
              >>> @@ -197,7 +197,7 @@ buf_init_chartab(buf, global)
              >>> #endif
              >>> c2 = *p++;
              >>> }
              >>> - if (c <= 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256
              >>> + if (c < 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256
              >>> || !(*p == NUL || *p == ','))
              >>> return FAIL;
              >>
              >> Well, this allows having a zero in the option value, but I very much
              >> doubt it actually works. In C the zero is used to terminate a string,
              >> thus sending a zero to the terminal just won't work.
              >
              > Well, at least I can do this in a terminal:
              >
              > $ printf "foo\0bar\n"
              > foobar
              >
              > Seems like Bash handles this somehow, and the NUL is skipped / prints as
              > nothing.
              >
              >> If you want to *display* control characters you need to do something
              >> else anyway, since sending a BS or other control character won't result
              >> in displaying anything.
              >
              > The OP's use case is representing every character by a single display
              > cell. Obviously, BS will mess up things. But probably, a (binary) file
              > won't contain many of those (in the area of interest), but possibly a
              > lot of NULs. Skipping those in the output might be okay for his use.

              I've just tested Christian's patch (on Ubuntu 13.10); adding 0 to
              'isprint' messes up the displayed window contents in terminal Vim, less
              so in GVIM (there, the NUL is shown as "?", but I still saw occasional
              glitches when navigating in the window).

              At least, no crashes or other critical problems. So, adding the patch
              would make the option more consistent by allowing the 0 value, even
              though it's questionable that the current behavior is of any actual use
              (but maybe this prompts someone to develop better support for that).

              -- regards, ingo

              --
              --
              You received this message from the "vim_dev" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_dev" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            Your message has been successfully submitted and would be delivered to recipients shortly.