Skip to content

Commit 82342c5

Browse files
brammooldouglasdrumond
authored andcommitted
patch 7.4.710 Problem: It is not possible to make spaces visibible in list mode. Solution: Add the "space" item to 'listchars'. (David Bürgin, issue 350)
1 parent f06523a commit 82342c5

File tree

12 files changed

+100
-15
lines changed

12 files changed

+100
-15
lines changed

runtime/doc/options.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4819,31 +4819,35 @@ A jump table for the options with a short description can be found at |Q_op|.
48194819
{not in Vi}
48204820
Strings to use in 'list' mode and for the |:list| command. It is a
48214821
comma separated list of string settings.
4822-
*lcs-eol*
4822+
*lcs-eol*
48234823
eol:c Character to show at the end of each line. When
48244824
omitted, there is no extra character at the end of the
48254825
line.
4826-
*lcs-tab*
4826+
*lcs-tab*
48274827
tab:xy Two characters to be used to show a tab. The first
48284828
char is used once. The second char is repeated to
48294829
fill the space that the tab normally occupies.
48304830
"tab:>-" will show a tab that takes four spaces as
48314831
">---". When omitted, a tab is show as ^I.
4832-
*lcs-trail*
4832+
*lcs-space*
4833+
space:c Character to show for a space. When omitted, spaces
4834+
are left blank.
4835+
*lcs-trail*
48334836
trail:c Character to show for trailing spaces. When omitted,
4834-
trailing spaces are blank.
4835-
*lcs-extends*
4837+
trailing spaces are blank. Overrides the "space"
4838+
setting for trailing spaces.
4839+
*lcs-extends*
48364840
extends:c Character to show in the last column, when 'wrap' is
48374841
off and the line continues beyond the right of the
48384842
screen.
4839-
*lcs-precedes*
4843+
*lcs-precedes*
48404844
precedes:c Character to show in the first column, when 'wrap'
48414845
is off and there is text preceding the character
48424846
visible in the first column.
4843-
*lcs-conceal*
4847+
*lcs-conceal*
48444848
conceal:c Character to show in place of concealed text, when
48454849
'conceallevel' is set to 1.
4846-
*lcs-nbsp*
4850+
*lcs-nbsp*
48474851
nbsp:c Character to show for a non-breakable space (character
48484852
0xA0, 160). Left blank when omitted.
48494853

@@ -4856,7 +4860,7 @@ A jump table for the options with a short description can be found at |Q_op|.
48564860
:set lcs=tab:>-,eol:<,nbsp:%
48574861
:set lcs=extends:>,precedes:<
48584862
< The "NonText" highlighting will be used for "eol", "extends" and
4859-
"precedes". "SpecialKey" for "nbsp", "tab" and "trail".
4863+
"precedes". "SpecialKey" for "nbsp", "space", "tab" and "trail".
48604864
|hl-NonText| |hl-SpecialKey|
48614865

48624866
*'lpl'* *'nolpl'* *'loadplugins'* *'noloadplugins'*

src/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,7 @@ EXTERN int lcs_eol INIT(= '$');
11651165
EXTERN int lcs_ext INIT(= NUL);
11661166
EXTERN int lcs_prec INIT(= NUL);
11671167
EXTERN int lcs_nbsp INIT(= NUL);
1168+
EXTERN int lcs_space INIT(= NUL);
11681169
EXTERN int lcs_tab1 INIT(= NUL);
11691170
EXTERN int lcs_tab2 INIT(= NUL);
11701171
EXTERN int lcs_trail INIT(= NUL);

src/screen.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4334,14 +4334,16 @@ win_line(wp, lnum, startrow, endrow, nochange)
43344334
#endif
43354335
++ptr;
43364336

4337-
/* 'list' : change char 160 to lcs_nbsp. */
4338-
if (wp->w_p_list && (c == 160
4337+
/* 'list': change char 160 to lcs_nbsp and space to lcs_space. */
4338+
if (wp->w_p_list
4339+
&& (((c == 160
43394340
#ifdef FEAT_MBYTE
4340-
|| (mb_utf8 && mb_c == 160)
4341+
|| (mb_utf8 && mb_c == 160)
43414342
#endif
4342-
) && lcs_nbsp)
4343+
) && lcs_nbsp)
4344+
|| (c == ' ' && lcs_space && ptr <= line + trailcol)))
43434345
{
4344-
c = lcs_nbsp;
4346+
c = (c == ' ') ? lcs_space : lcs_nbsp;
43454347
if (area_attr == 0 && search_attr == 0)
43464348
{
43474349
n_attr = 1;

src/testdir/Make_amiga.mak

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
4646
test_erasebackword.out \
4747
test_eval.out \
4848
test_insertcount.out \
49+
test_listchars.out \
4950
test_listlbr.out \
5051
test_listlbr_utf8.out \
5152
test_mapping.out \
@@ -189,6 +190,7 @@ test_command_count.out: test_command_count.in
189190
test_erasebackword.out: test_erasebackword.in
190191
test_eval.out: test_eval.in
191192
test_insertcount.out: test_insertcount.in
193+
test_listchars.out: test_listchars.in
192194
test_listlbr.out: test_listlbr.in
193195
test_listlbr_utf8.out: test_listlbr_utf8.in
194196
test_mapping.out: test_mapping.in

src/testdir/Make_dos.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
4545
test_erasebackword.out \
4646
test_eval.out \
4747
test_insertcount.out \
48+
test_listchars.out \
4849
test_listlbr.out \
4950
test_listlbr_utf8.out \
5051
test_mapping.out \

src/testdir/Make_ming.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
6767
test_erasebackword.out \
6868
test_eval.out \
6969
test_insertcount.out \
70+
test_listchars.out \
7071
test_listlbr.out \
7172
test_listlbr_utf8.out \
7273
test_mapping.out \

src/testdir/Make_os2.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
4747
test_erasebackword.out \
4848
test_eval.out \
4949
test_insertcount.out \
50+
test_listchars.out \
5051
test_listlbr.out \
5152
test_listlbr_utf8.out \
5253
test_mapping.out \

src/testdir/Make_vms.mms

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Authors: Zoltan Arpadffy, <arpadffy@polarhome.com>
55
# Sandor Kopanyi, <sandor.kopanyi@mailbox.hu>
66
#
7-
# Last change: 2015 Mar 24
7+
# Last change: 2015 Apr 21
88
#
99
# This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
1010
# Edit the lines in the Configuration section below to select.
@@ -106,6 +106,7 @@ SCRIPT = test1.out test2.out test3.out test4.out test5.out \
106106
test_erasebackword.out \
107107
test_eval.out \
108108
test_insertcount.out \
109+
test_listchars.out \
109110
test_listlbr.out \
110111
test_listlbr_utf8.out \
111112
test_mapping.out \

src/testdir/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
4343
test_erasebackword.out \
4444
test_eval.out \
4545
test_insertcount.out \
46+
test_listchars.out \
4647
test_listlbr.out \
4748
test_listlbr_utf8.out \
4849
test_mapping.out \

src/testdir/test_listchars.in

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Tests for 'listchars' display with 'list' and :list
2+
3+
STARTTEST
4+
:so small.vim
5+
:let g:lines = []
6+
:function GetScreenCharsForLine(lnum)
7+
: return join(map(range(1, virtcol('$')), 'nr2char(screenchar(a:lnum, v:val))'), '')
8+
:endfunction
9+
:nnoremap <expr> GG ":call add(g:lines, GetScreenCharsForLine(".screenrow()."))\<CR>"
10+
:set listchars+=tab:>-,space:.,trail:<
11+
:set list
12+
:
13+
/^start:/
14+
:normal! jzt
15+
GG
16+
GG
17+
GG
18+
GG
19+
GGH:
20+
:set listchars-=trail:<
21+
GG
22+
GG
23+
GG
24+
GG
25+
GG:
26+
:put =g:lines
27+
:'[,']w! test.out
28+
ENDTEST
29+
30+
start:
31+
aa
32+
bb
33+
cccc
34+
dd ee
35+
36+
37+
38+
STARTTEST
39+
:set listchars+=trail:<
40+
:set nolist
41+
:
42+
/^start:/
43+
:redir! >> test.out
44+
:+1,$list
45+
:redir END
46+
:q!
47+
ENDTEST
48+
49+
start:
50+
fff
51+
gg
52+
h
53+
iii

0 commit comments

Comments
 (0)