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

Re: Patch: support for the "space" argument for "listchars"

Expand Messages
  • Jesus Antonio Santos Giraldo
    je je... I mean, if even Microsoft Word can show space characters ... nice catch ! Interesting link on stackoverflow BTW. J. 2013/8/19 glts
    Message 1 of 27 , Aug 19, 2013
    • 0 Attachment
      je je... "I mean, if even Microsoft Word can show space characters"... nice catch !

      Interesting link on stackoverflow BTW.


      J.


      2013/8/19 glts <676c7473@...>
      On Mon, Aug 19, 2013 at 12:41 AM, Jesus Antonio Santos Giraldo
      <jeansagi@...> wrote:
      > Almost a year later since last comment, Vim 7.4 is out... and again there is no *space* option for listchars... :( :( :(
      >
      > Maybe anyone has implemented this patch in 7.4? If so, I really appreciate it.
      > As I said a year ago, "It would be very, very, very usefull for my work".
      >
      >
      > J.
      >
      > El viernes, 31 de agosto de 2012 17:34:16 UTC-5, Jesus Antonio Santos Giraldo escribió:
      >> El lunes, 27 de agosto de 2012 05:59:48 UTC-5, 柳永峰 escribió:
      >> > hi thanks,it's very useful to me
      >> >
      >> > On Wednesday, October 21, 2009 10:26:10 PM UTC+8, Arkanosis wrote:
      >> > > Hello,
      >> > >
      >> > > I've just started to use Vim, and missed the possibility to display
      >> > > middle-dots (or any other visible character) instead of spaces, so I
      >> > > made the following patch.
      >> > > It adds "space" in the allowed "listchars" arguments.
      >> > >
      >> > > Just in case someone find this useful ; I found easier to patch Vim
      >> > > than to look for another existing solution ;-)
      >> > >
      >> > > Best regards,
      >> > >
      >> > > Index: option.c
      >> > > ===================================================================
      >> > > --- option.c      (revision 1626)
      >> > > +++ option.c      (working copy)
      >> > > @@ -6847,6 +6847,7 @@
      >> > >   {&lcs_ext,      "extends"},
      >> > >   {&lcs_nbsp,     "nbsp"},
      >> > >   {&lcs_prec,     "precedes"},
      >> > > + {&lcs_space,    "space"},
      >> > >   {&lcs_tab2,     "tab"},
      >> > >   {&lcs_trail,    "trail"},
      >> > >      };
      >> > > Index: screen.c
      >> > > ===================================================================
      >> > > --- screen.c      (revision 1626)
      >> > > +++ screen.c      (working copy)
      >> > > @@ -3886,6 +3886,18 @@
      >> > >  #endif
      >> > >       }
      >> > >
      >> > > +     /* 'list' : change space to lcs_space. */
      >> > > +     if (wp->w_p_list && c == ' ' && lcs_space)
      >> > > +     {
      >> > > +         c = lcs_space;
      >> > > +         if (area_attr == 0 && search_attr == 0)
      >> > > +         {
      >> > > +             n_attr = 1;
      >> > > +             extra_attr = hl_attr(HLF_8);
      >> > > +             saved_attr2 = char_attr; /* save current attr */
      >> > > +         }
      >> > > +     }
      >> > > +
      >> > >       if (extra_check)
      >> > >       {
      >> > >  #ifdef FEAT_SPELL
      >> > > @@ -4040,7 +4052,7 @@
      >> > >           }
      >> > >  #endif
      >> > >
      >> > > -         if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
      >> > > +         if (trailcol != MAXCOL && ptr > line + trailcol && (c == ' ' || c
      >> > > == lcs_space))
      >> > >           {
      >> > >               c = lcs_trail;
      >> > >               if (!attr_pri)
      >> > > Index: globals.h
      >> > > ===================================================================
      >> > > --- globals.h     (revision 1626)
      >> > > +++ globals.h     (working copy)
      >> > > @@ -1146,6 +1146,7 @@
      >> > >  EXTERN int       lcs_tab1 INIT(= NUL);
      >> > >  EXTERN int       lcs_tab2 INIT(= NUL);
      >> > >  EXTERN int       lcs_trail INIT(= NUL);
      >> > > +EXTERN int       lcs_space INIT(= NUL);
      >> > >
      >> > >  #if defined(FEAT_WINDOWS) || defined(FEAT_WILDMENU) || defined(FEAT_STL_OPT) \
      >> > >   || defined(FEAT_FOLDING)
      >> > >
      >> > > --
      >> > > Jérémie Roquet - Arkanosis
      >> > > Programming artist
      >> > > Developer in natural language processing - Exalead
      >>
      >> That would be very useful for me!
      >>
      >>
      >>
      >> I'm developing a plaint text file now and was very excited while reading how listchars works specially the trail option. However almost immediately I find myself googling the way to convert middle-dots... until I found this thread.
      >>
      >>
      >>
      >> So, really, I can see real benefits from having this, besides looking the patch it seems not so difficult to merge or maintain... ( Things are easier to do if you don't have to do them yourself ;) )
      >>
      >>
      >>
      >> If you ever consider the possibility of including this count me on to test it.

      +1

      I didn't know this patch existed. This is a common gripe, especially for
      people coming from other editors. I mean, if even Microsoft Word can
      show space characters ... :P

      There's a popular Stackoverflow thread about this:
      http://stackoverflow.com/q/1675688

      --
      --
      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 a topic in the Google Groups "vim_dev" group.
      To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_dev/dIQHjW1g92s/unsubscribe.
      To unsubscribe from this group and all its topics, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.

      --
      --
      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/groups/opt_out.
    • Jesus Antonio Santos Giraldo
      Good one. Didn t knew about _concealing_ but so far it looks like the best approach to show spaces that I ve seen. In my case I wanted to conceal a pure space
      Message 2 of 27 , Aug 19, 2013
      • 0 Attachment
        Good one.

        Didn't knew about _concealing_ but so far it looks like the best approach to show spaces that I've seen.
        In my case I wanted to conceal a pure space (0x32) not all whitespaces so I changed /\s/ with just a / /, otherwise tabulators and spaces would be concealed the same way.

        Anyway for me *listchars* seems like the way it should be .


        J.


        2013/8/19 Christian Brabandt <cblists@...>
        Hi Jesus!

        On So, 18 Aug 2013, Jesus Antonio Santos Giraldo wrote:

        > Not to mention that there is already a patch for it... :(

        All whitespace as something different? Can't you use the conceal feature
        for that?

        :syn match MyWhitespace /\s/ conceal cchar=_ containedin=ALL
        :setl conceallevel=2 concealcursor=nv

        regards,
        Christian
        --
        Sprachlexikon-Namen: NICOLE - immer pleite

        --
        --
        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 a topic in the Google Groups "vim_dev" group.
        To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_dev/dIQHjW1g92s/unsubscribe.
        To unsubscribe from this group and all its topics, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.

        --
        --
        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/groups/opt_out.
      • Ingo Karkat
        ... Note that concealing has to extend the existing syntax, which can break it. You need autocmds to set it up (and keep it when the syntax changes). And it s
        Message 3 of 27 , Aug 20, 2013
        • 0 Attachment
          On 20-Aug-2013 02:16 +0200, Jesus Antonio Santos Giraldo wrote:

          > Good one.
          >
          > Didn't knew about _concealing_ but so far it looks like the best
          > approach to show spaces that I've seen.

          Note that concealing has to extend the existing syntax, which can break
          it. You need autocmds to set it up (and keep it when the syntax
          changes). And it's buffer-local, not window-local like :set list. So
          while it is a workaround, it is not a particularly good one.

          > [3 lines deleted]

          > Anyway for me *listchars* seems like the way it should be .

          Since there seems to be quite some interest in this, offering this via
          'listchars' indeed looks like the preferable solution. +1

          -- regards, ingo

          PS: Do not top-post! Type your reply below the text you are replying to.

          --
          --
          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/groups/opt_out.
        • Christian Brabandt
          ... Well changing the syntax rules is of course a way of breaking it, but I think it should work well enough most of the times. And while I am not very
          Message 4 of 27 , Aug 20, 2013
          • 0 Attachment
            On Tue, August 20, 2013 09:02, Ingo Karkat wrote:
            > Note that concealing has to extend the existing syntax, which can break
            > it.

            Well changing the syntax rules is of course a way of breaking it, but
            I think it should work well enough most of the times. And while I am not
            very proficient with syntax highlighting, I haven't seen it break yet.

            > You need autocmds to set it up (and keep it when the syntax
            > changes).

            You usually want to create a toggle, so you could simply create a
            custom command that set's up the highlighting. To disable it, it
            should be enough to call :syntax enable. Not sure, how often you will
            encounter "syntax changes" after the buffer has been loaded into a window.

            > And it's buffer-local, not window-local like :set list. So
            > while it is a workaround, it is not a particularly good one.

            You can use :ownsyntax to work around this as well.

            >> Anyway for me *listchars* seems like the way it should be .
            >
            > Since there seems to be quite some interest in this, offering this via
            > 'listchars' indeed looks like the preferable solution. +1

            I don't have a particular strong opinion about that, I just wanted to
            point out an existing alternative.

            regards,
            Christian

            --
            --
            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/groups/opt_out.
          • glts
            On Mon, Aug 19, 2013 at 12:41 AM, Jesus Antonio Santos Giraldo ... Bram, I ve updated and tightened the patch a bit. Printing of lcs_space with ... help, I
            Message 5 of 27 , Aug 24, 2013
            • 0 Attachment
              On Mon, Aug 19, 2013 at 12:41 AM, Jesus Antonio Santos Giraldo
              <jeansagi@...> wrote:
              > Almost a year later since last comment, Vim 7.4 is out... and again there is no *space* option for listchars... :( :( :(
              >
              > Maybe anyone has implemented this patch in 7.4? If so, I really appreciate it.
              > As I said a year ago, "It would be very, very, very usefull for my work".
              >
              >
              > J.
              >
              > El viernes, 31 de agosto de 2012 17:34:16 UTC-5, Jesus Antonio Santos Giraldo escribió:
              >> El lunes, 27 de agosto de 2012 05:59:48 UTC-5, 柳永峰 escribió:
              >> > hi thanks,it's very useful to me
              >> >
              >> > On Wednesday, October 21, 2009 10:26:10 PM UTC+8, Arkanosis wrote:
              >> > > Hello,
              >> > >
              >> > > I've just started to use Vim, and missed the possibility to display
              >> > > middle-dots (or any other visible character) instead of spaces, so I
              >> > > made the following patch.
              >> > > It adds "space" in the allowed "listchars" arguments.
              >> > >
              >> > > Just in case someone find this useful ; I found easier to patch Vim
              >> > > than to look for another existing solution ;-)
              >> > >
              >> > > Best regards,
              >> > >
              >> > > Index: option.c
              >> > > ===================================================================
              >> > > --- option.c (revision 1626)
              >> > > +++ option.c (working copy)
              >> > > @@ -6847,6 +6847,7 @@
              >> > > {&lcs_ext, "extends"},
              >> > > {&lcs_nbsp, "nbsp"},
              >> > > {&lcs_prec, "precedes"},
              >> > > + {&lcs_space, "space"},
              >> > > {&lcs_tab2, "tab"},
              >> > > {&lcs_trail, "trail"},
              >> > > };
              >> > > Index: screen.c
              >> > > ===================================================================
              >> > > --- screen.c (revision 1626)
              >> > > +++ screen.c (working copy)
              >> > > @@ -3886,6 +3886,18 @@
              >> > > #endif
              >> > > }
              >> > >
              >> > > + /* 'list' : change space to lcs_space. */
              >> > > + if (wp->w_p_list && c == ' ' && lcs_space)
              >> > > + {
              >> > > + c = lcs_space;
              >> > > + if (area_attr == 0 && search_attr == 0)
              >> > > + {
              >> > > + n_attr = 1;
              >> > > + extra_attr = hl_attr(HLF_8);
              >> > > + saved_attr2 = char_attr; /* save current attr */
              >> > > + }
              >> > > + }
              >> > > +
              >> > > if (extra_check)
              >> > > {
              >> > > #ifdef FEAT_SPELL
              >> > > @@ -4040,7 +4052,7 @@
              >> > > }
              >> > > #endif
              >> > >
              >> > > - if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
              >> > > + if (trailcol != MAXCOL && ptr > line + trailcol && (c == ' ' || c
              >> > > == lcs_space))
              >> > > {
              >> > > c = lcs_trail;
              >> > > if (!attr_pri)
              >> > > Index: globals.h
              >> > > ===================================================================
              >> > > --- globals.h (revision 1626)
              >> > > +++ globals.h (working copy)
              >> > > @@ -1146,6 +1146,7 @@
              >> > > EXTERN int lcs_tab1 INIT(= NUL);
              >> > > EXTERN int lcs_tab2 INIT(= NUL);
              >> > > EXTERN int lcs_trail INIT(= NUL);
              >> > > +EXTERN int lcs_space INIT(= NUL);
              >> > >
              >> > > #if defined(FEAT_WINDOWS) || defined(FEAT_WILDMENU) || defined(FEAT_STL_OPT) \
              >> > > || defined(FEAT_FOLDING)
              >> > >
              >> > > --
              >> > > Jérémie Roquet - Arkanosis
              >> > > Programming artist
              >> > > Developer in natural language processing - Exalead
              >>
              >> That would be very useful for me!
              >>
              >>
              >>
              >> I'm developing a plaint text file now and was very excited while reading how listchars works specially the trail option. However almost immediately I find myself googling the way to convert middle-dots... until I found this thread.
              >>
              >>
              >>
              >> So, really, I can see real benefits from having this, besides looking the patch it seems not so difficult to merge or maintain... ( Things are easier to do if you don't have to do them yourself ;) )
              >>
              >>
              >>
              >> If you ever consider the possibility of including this count me on to test it.

              Bram,

              I've updated and tightened the patch a bit. Printing of lcs_space with
              :list was missing, I added this. There were a few stray spaces in the
              help, I cleaned this up too, while I was at it. I also added tests, for
              'list' and :list.

              By the way: introducing the new screenchar() to the test suite, it was
              quite useful for writing the test.

              I figured a little less complaining, a little more action would be in
              order. :)

              Best,



              --
              David Bürgin

              --
              --
              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/groups/opt_out.
            • glts
              Dear Bram and list, ... I have updated this patch to apply cleanly to the current Vim version 7.4.471. Anecdote to accompany the patch. If you wish, take a
              Message 6 of 27 , Oct 10, 2014
              • 0 Attachment
                Dear Bram and list,

                On Saturday, August 24, 2013 1:54:14 PM UTC+2, glts wrote:
                > On Mon, Aug 19, 2013 at 12:41 AM, Jesus Antonio Santos Giraldo
                > <jeansagi@...> wrote:
                > > Almost a year later since last comment, Vim 7.4 is out... and again there is no *space* option for listchars... :( :( :(
                > >
                > > Maybe anyone has implemented this patch in 7.4? If so, I really appreciate it.
                > > As I said a year ago, "It would be very, very, very usefull for my work".
                > >
                > >
                > > J.
                > >
                > > El viernes, 31 de agosto de 2012 17:34:16 UTC-5, Jesus Antonio Santos Giraldo escribió:
                > >> El lunes, 27 de agosto de 2012 05:59:48 UTC-5, 柳永峰 escribió:
                > >> > hi thanks,it's very useful to me
                > >> >
                > >> > On Wednesday, October 21, 2009 10:26:10 PM UTC+8, Arkanosis wrote:
                > >> > > Hello,
                > >> > >
                > >> > > I've just started to use Vim, and missed the possibility to display
                > >> > > middle-dots (or any other visible character) instead of spaces, so I
                > >> > > made the following patch.
                > >> > > It adds "space" in the allowed "listchars" arguments.
                > >> > >
                > >> > > Just in case someone find this useful ; I found easier to patch Vim
                > >> > > than to look for another existing solution ;-)
                > >> > >
                > >> > > Best regards,
                > >> > >
                > >> > > Index: option.c
                > >> > > ===================================================================
                > >> > > --- option.c (revision 1626)
                > >> > > +++ option.c (working copy)
                > >> > > @@ -6847,6 +6847,7 @@
                > >> > > {&lcs_ext, "extends"},
                > >> > > {&lcs_nbsp, "nbsp"},
                > >> > > {&lcs_prec, "precedes"},
                > >> > > + {&lcs_space, "space"},
                > >> > > {&lcs_tab2, "tab"},
                > >> > > {&lcs_trail, "trail"},
                > >> > > };
                > >> > > Index: screen.c
                > >> > > ===================================================================
                > >> > > --- screen.c (revision 1626)
                > >> > > +++ screen.c (working copy)
                > >> > > @@ -3886,6 +3886,18 @@
                > >> > > #endif
                > >> > > }
                > >> > >
                > >> > > + /* 'list' : change space to lcs_space. */
                > >> > > + if (wp->w_p_list && c == ' ' && lcs_space)
                > >> > > + {
                > >> > > + c = lcs_space;
                > >> > > + if (area_attr == 0 && search_attr == 0)
                > >> > > + {
                > >> > > + n_attr = 1;
                > >> > > + extra_attr = hl_attr(HLF_8);
                > >> > > + saved_attr2 = char_attr; /* save current attr */
                > >> > > + }
                > >> > > + }
                > >> > > +
                > >> > > if (extra_check)
                > >> > > {
                > >> > > #ifdef FEAT_SPELL
                > >> > > @@ -4040,7 +4052,7 @@
                > >> > > }
                > >> > > #endif
                > >> > >
                > >> > > - if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
                > >> > > + if (trailcol != MAXCOL && ptr > line + trailcol && (c == ' ' || c
                > >> > > == lcs_space))
                > >> > > {
                > >> > > c = lcs_trail;
                > >> > > if (!attr_pri)
                > >> > > Index: globals.h
                > >> > > ===================================================================
                > >> > > --- globals.h (revision 1626)
                > >> > > +++ globals.h (working copy)
                > >> > > @@ -1146,6 +1146,7 @@
                > >> > > EXTERN int lcs_tab1 INIT(= NUL);
                > >> > > EXTERN int lcs_tab2 INIT(= NUL);
                > >> > > EXTERN int lcs_trail INIT(= NUL);
                > >> > > +EXTERN int lcs_space INIT(= NUL);
                > >> > >
                > >> > > #if defined(FEAT_WINDOWS) || defined(FEAT_WILDMENU) || defined(FEAT_STL_OPT) \
                > >> > > || defined(FEAT_FOLDING)
                > >> > >
                > >> > > --
                > >> > > Jérémie Roquet - Arkanosis
                > >> > > Programming artist
                > >> > > Developer in natural language processing - Exalead
                > >>
                > >> That would be very useful for me!
                > >>
                > >>
                > >>
                > >> I'm developing a plaint text file now and was very excited while reading how listchars works specially the trail option. However almost immediately I find myself googling the way to convert middle-dots... until I found this thread.
                > >>
                > >>
                > >>
                > >> So, really, I can see real benefits from having this, besides looking the patch it seems not so difficult to merge or maintain... ( Things are easier to do if you don't have to do them yourself ;) )
                > >>
                > >>
                > >>
                > >> If you ever consider the possibility of including this count me on to test it.
                >
                > Bram,
                >
                > I've updated and tightened the patch a bit. Printing of lcs_space with
                > :list was missing, I added this. There were a few stray spaces in the
                > help, I cleaned this up too, while I was at it. I also added tests, for
                > 'list' and :list.
                >
                > By the way: introducing the new screenchar() to the test suite, it was
                > quite useful for writing the test.
                >
                > I figured a little less complaining, a little more action would be in
                > order. :)

                I have updated this patch to apply cleanly to the current Vim version
                7.4.471.

                Anecdote to accompany the patch. If you wish, take a look at this
                screenshot I took the other day:
                https://raw.githubusercontent.com/glts/listchars-example/master/listchars-example.png
                Looks like a tab-separated values file, doesn't it? Unfortunately, in
                some columns tab is followed by one space, and this remains hidden even
                though 'list' is set. This one took a minute to figure out ...

                Thanks,
                and have a nice day.


                --
                David Bürgin

                --
                --
                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.