Skip to content

Add lcs-multispace to show multiple consecutive spaces differently#8834

Closed
zeertzjq wants to merge 1 commit intovim:masterfrom
zeertzjq:lcs-contig
Closed

Add lcs-multispace to show multiple consecutive spaces differently#8834
zeertzjq wants to merge 1 commit intovim:masterfrom
zeertzjq:lcs-contig

Conversation

@zeertzjq
Copy link
Member

@zeertzjq zeertzjq commented Sep 3, 2021

This is useful if one doesn't want to show single spaces (around operators or between words) so that it doesn't hinder code (or text) reading, while still wants to be able to show multiple consecutive spaces to make it easier count the number of spaces in a string or something else. I can recall that some other code editors (maybe VSCode) have this feature.

@codecov
Copy link

codecov bot commented Sep 3, 2021

Codecov Report

Merging #8834 (35d1e2d) into master (0780204) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

❗ Current head 35d1e2d differs from pull request most recent head f8be693. Consider uploading reports for the commit f8be693 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8834      +/-   ##
==========================================
- Coverage   90.18%   90.15%   -0.04%     
==========================================
  Files         151      147       -4     
  Lines      170880   170175     -705     
==========================================
- Hits       154102   153413     -689     
+ Misses      16778    16762      -16     
Flag Coverage Δ
huge-clang-none 89.46% <100.00%> (+0.12%) ⬆️
huge-gcc-none 89.67% <100.00%> (+0.01%) ⬆️
huge-gcc-testgui 88.30% <100.00%> (-0.01%) ⬇️
huge-gcc-unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/drawline.c 86.26% <100.00%> (+0.11%) ⬆️
src/message.c 87.10% <100.00%> (-0.52%) ⬇️
src/screen.c 86.90% <100.00%> (+0.39%) ⬆️
src/json.c 91.70% <0.00%> (-1.12%) ⬇️
src/strings.c 95.86% <0.00%> (-0.60%) ⬇️
src/crypt.c 84.46% <0.00%> (-0.54%) ⬇️
src/findfile.c 88.63% <0.00%> (-0.50%) ⬇️
src/gui.c 72.02% <0.00%> (-0.43%) ⬇️
src/if_xcmdsrv.c 88.73% <0.00%> (-0.36%) ⬇️
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0780204...f8be693. Read the comment docs.

@chrisbra
Copy link
Member

chrisbra commented Sep 3, 2021

Isn't that something, that you can already do using something like this:

call matchadd('Conceal', ' \@<= ', 10, -1, {'conceal':'—'})
call matchadd('Conceal', '\S\zs  \@=', 10, -1, {'conceal':'—'})

@zeertzjq
Copy link
Member Author

zeertzjq commented Sep 3, 2021

This requires setting conceallevel=2 and concealcursor=nvic (maybe?) to achieve the effect similar to listchars, which is not very convenient in some cases (e.g. when editing LaTeX files).

@chrisbra
Copy link
Member

chrisbra commented Sep 3, 2021

Well yes, and in your case it needs an additional :set list. I am just wondering if the maintenance burden for adding that feature is justified, considering, that we already have a feature that allows this as well.

@zeertzjq
Copy link
Member Author

zeertzjq commented Sep 3, 2021

Everything in listchars can be toggled on and off, so it is unlikely that this will conflict with other use cases, unlike conceallevel and concealcursor which affect everything that use the conceal feature.

@zeertzjq
Copy link
Member Author

zeertzjq commented Sep 3, 2021

This requires setting conceallevel=2 and concealcursor=nvic (maybe?) to achieve the effect similar to listchars, which is not very convenient in some cases (e.g. when editing LaTeX files).

Maybe "convenient" is not the right word here. I wanted to mean that it may conflict with other use cases of conceal, especially those that don't work well with concealcursor=nvic.

@zeertzjq zeertzjq changed the title Add lcs-contig two show two or more contiguous spaces differently Add lcs-contig to show two or more contiguous spaces differently Sep 4, 2021
@brammool
Copy link
Contributor

brammool commented Sep 4, 2021

Instead of a single character, how about making this a string? E.g. setting it to "---+" would show a longer sequence of spaces as "---+---+---+". Would not be used for a single space.

@zeertzjq
Copy link
Member Author

zeertzjq commented Sep 4, 2021

Instead of a single character, how about making this a string? E.g. setting it to "---+" would show a longer sequence of spaces as "---+---+---+". Would not be used for a single space.

Should the string be char_u * or int * in structs.h?

@zeertzjq zeertzjq marked this pull request as draft September 4, 2021 14:32
@zeertzjq
Copy link
Member Author

zeertzjq commented Sep 5, 2021

I'm using int *.

@zeertzjq zeertzjq marked this pull request as ready for review September 5, 2021 01:15
@zeertzjq
Copy link
Member Author

zeertzjq commented Sep 5, 2021

I think this is done now.

@zeertzjq
Copy link
Member Author

zeertzjq commented Sep 8, 2021

Several continue; statements in set_chars_option always lead to return e_invarg; (as the value of pointer p is not changed). Maybe they can be changed to return e_invarg; to be more straightforward?

@brammool
Copy link
Contributor

brammool commented Sep 8, 2021

This is starting to look good. A couple of notes.

The name "contig" is not at all obvious. How about "multspace"? or "space2"?

The help should give an example, e.g. "---.---+".

@zeertzjq zeertzjq changed the title Add lcs-contig to show two or more contiguous spaces differently Add lcs-multispace to show multiple consecutive spaces differently Sep 8, 2021
@zeertzjq
Copy link
Member Author

zeertzjq commented Sep 8, 2021

It seems "multiple" is more often abbreviated to "multi" than as "mult" in Vim. "multispace" indeed seems a more straightforward name.

@brammool brammool closed this in f14b8ba Sep 10, 2021
@zeertzjq zeertzjq deleted the lcs-contig branch September 10, 2021 21:44
lewis6991 pushed a commit to lewis6991/neovim that referenced this pull request Dec 12, 2021
Problem:    A sequence of spaces is hard to see in list mode.
Solution:   Add the "multispace" option to 'listchars'. (closes vim/vim#8834)
vim/vim@f14b8ba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants