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
Nice! Bram, any chance this could become official?
--
Steve Hall [ digitect dancingpaper com ]
I'm sorry, the previous patch cause a segmentation fault if you don't
use the "space" argument.
The following fixes this (added "&& lcs_space" in screen.c).
Again, sorry for this.
Best regards,
== lcs_space && lcs_space))
> 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 ;-)
I'm confused. It appears the "space" character is both used to display
instead of a space character when 'list' is on, and to find this
character after the end of the line and replace it with "trail".
To me these are two unrelated things.
I'm not sure how useful it is to show something instead of a space.
Isn't it obvious that there is a space when there is nothing?
--
Two cows are standing together in a field. One asks the other:
"So what do you think about this Mad Cow Disease?"
The other replies: "That doesn't concern me. I'm a helicopter."
/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Bram, I can't speak for the author, but I'd like this feature to make
it easy to visualize:
* other non-printing characters that look like dec 032
* double spaces
* spaces after chars at window edges with wrap on
* every char as a byte
Currently, Vim can show every "invisible" character except
intermediate spaces, why not add it and be complete? :)
2009/10/28 Bram Moolenaar <Br...@moolenaar.net>:
>> It adds "space" in the allowed "listchars" arguments.
> I'm confused. It appears the "space" character is both used to display
> instead of a space character when 'list' is on, and to find this
> character after the end of the line and replace it with "trail".
> To me these are two unrelated things.
You are right. This was because spaces were already replaced at that
point, making the replacement with "trail" impossible.
But it leads to side effects if the "space replacement" character is
actually used in the edited file.
Here is a new patch without this annoying side-effect.
> I'm not sure how useful it is to show something instead of a space.
> Isn't it obvious that there is a space when there is nothing?
Sometimes it's not : I'm using a visible character for the first
column of tabs, but an invisible one for the remaining columns.
So cases where a tab is followed by a space are not that obvious.
And as Steve pointed out, double spaces are not always obvious either.
2009/10/29 Steve Hall <digi...@dancingpaper.com>
> Bram, I can't speak for the author, but I'd like this feature to make
> it easy to visualize:
> * other non-printing characters that look like dec 032
> * double spaces
> * spaces after chars at window edges with wrap on
> * every char as a byte
As for now, only the ' ' character is displayed, but it'd easy to support more.
Best regards,
Index: src/option.c
===================================================================
--- src/option.c (revision 1626)
+++ src/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: src/screen.c
===================================================================
--- src/screen.c (revision 1626)
+++ src/screen.c (working copy)
@@ -3886,6 +3886,29 @@
#endif
}
+ /* 'list' : change space to lcs_space. */
+ if (wp->w_p_list && c == ' ' && lcs_space && ptr <= line + trailcol)
+ {
+ 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 */
+ }
+#ifdef FEAT_MBYTE
+ mb_c = c;
+ if (enc_utf8 && (*mb_char2len)(c) > 1)
+ {
+ mb_utf8 = TRUE;
+ u8cc[0] = 0;
+ c = 0xc0;
+ }
+ else
+ mb_utf8 = FALSE;
+#endif
+ }
+
if (extra_check)
{
#ifdef FEAT_SPELL
Index: src/globals.h
===================================================================
--- src/globals.h (revision 1626)
+++ src/globals.h (working copy)
Well, I might consider including this. Can you write a patch for the
documentation as well?
--
TALL KNIGHT: When you have found the shrubbery, then you must cut down the
mightiest tree in the forest ... with a herring.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Sure.
Here is what I supposed was to be updated; please let me know if there
is some other documentation to patch.
Best regards,
Index: runtime/doc/options.txt
===================================================================
--- runtime/doc/options.txt (revision 1626)
+++ runtime/doc/options.txt (working copy)
@@ -4360,17 +4360,19 @@
visible in the first column.
nbsp:c Character to show for a non-breakable space (character
0xA0, 160). Left blank when omitted.
+ space:c Character to show for a space (character 0x20, 32). Left
+ blank when omitted.
The characters ':' and ',' should not be used. UTF-8 characters can
be used when 'encoding' is "utf-8", otherwise only printable
characters are allowed. All characters must be single width.
Examples: >
- :set lcs=tab:>-,trail:-
+ :set lcs=tab:>-,trail:-,space:.
:set lcs=tab:>-,eol:<,nbsp:%
:set lcs=extends:>,precedes:<
< The "NonText" highlighting will be used for "eol", "extends" and
- "precedes". "SpecialKey" for "nbsp", "tab" and "trail".
+ "precedes". "SpecialKey" for "nbsp", "space", "tab" and "trail".
|hl-NonText| |hl-SpecialKey|
*'lpl'* *'nolpl'* *'loadplugins'* *'noloadplugins'*
I know this thread is from 2009 and I hope I'm not stomping on some kind of
list etiquette by bringing it back to life, but I'm wondering what happened
to this patch to enable a "space" option for listchars?
As far as I can tell it never made it in to the official code, as it doesn't
function in my version of gvim 7.3. I'd really like to have the option, so
I'm curious if the patch was never integrated as a design decision or if
there was something wrong with the code or documentation patch I could help
improve?
-- jmp
--
View this message in context: http://vim.1045645.n5.nabble.com/Patch-support-for-the-space-argument-for-listchars-tp1210494p4873477.html
Sent from the Vim - Dev mailing list archive at Nabble.com.
On Mi, 05 Okt 2011, jpetrie wrote:
> > J�r�mie Roquet wrote:
> >> 2009/10/28 Bram Moolenaar <[hidden email]>:
> >> >> It adds "space" in the allowed "listchars" arguments.
> >> > I'm not sure how useful it is to show something instead of a space.
> >> > Isn't it obvious that there is a space when there is nothing?
> >> Sometimes it's not : I'm using a visible character for the first
> >> column of tabs, but an invisible one for the remaining columns.
> >> So cases where a tab is followed by a space are not that obvious.
> >> And as Steve pointed out, double spaces are not always obvious either.
> > Well, I might consider including this. Can you write a patch for the
> > documentation as well?
>
> I know this thread is from 2009 and I hope I'm not stomping on some kind of
> list etiquette by bringing it back to life, but I'm wondering what happened
> to this patch to enable a "space" option for listchars?
>
> As far as I can tell it never made it in to the official code, as it doesn't
> function in my version of gvim 7.3. I'd really like to have the option, so
> I'm curious if the patch was never integrated as a design decision or if
> there was something wrong with the code or documentation patch I could help
> improve?
Can you point me to the patch?
regards,
Christian
--
It's in the todo list (c.f., :help todo).
> Can you point me to the patch?
http://mid.gmane.org/19e866460910290309w27...@mail.gmail.com
--
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <jame...@jamessan.com>
Thanks, applies, but needs some updates.
Bram, would you like an updated patch, including documentation?
regards,
Christian
--
Linux wird nie zum meistinstallierten System -
so oft wie man Windows neu installieren darf.
We already have enough options to completely confuse a beginning user.
Every time a proposal is made to add another option or option value, the
question is: do we really need this? How many people would actually
use it? Isn't there another way to do almost the same?
You can at least use :match if you want to highlight specific use of
spaces.
I have been overwhelmed with bugs and bug fixes, these always go before
new features, especially when I'm not sure if it's a useful feature.
And also because new features tend to introduce new bugs that then have
to be fixed...
--
hundred-and-one symptoms of being an internet addict:
39. You move into a new house and decide to Netscape before you landscape.
/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.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 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+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
--
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.