Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

75%
+4 −0
Q&A Syntax match any 2 spaces at end of line

I'm using the following syntax match to conceal 2 spaces at the end of a line with a special character. syntax match Normal '\s\{2}$' conceal cchar=⏎ A line with two spaces at the end of it wou...

2 answers  ·  posted 6mo ago by rcmosher‭  ·  last activity 6mo ago by Michael‭

Question vim
#2: Post edited by user avatar Michael‭ · 2024-05-22T19:48:27Z (6 months ago)
Fix typo. Block quotes in case we get viml syntax highlighting sometime.
Syntax match any 2 spaces at end of line
  • I'm using the following syntax match to conceal 2 spaces at the end of a line with a special character.
  • `syntax match Normal '\s\{2}$' conceal cchar=⏎`
  • A line with two spaces at the end of it would display like this:
  • `some line with two trailing spaces⏎`
  • However, if there are more than two spaces I don't get the special character. I would expect that this would still match on the last two spaces. For example:
  • `a line with 4 trailing spaces ⏎`
  • Instead it shows all 4 spaces with no special character.
  • If I do a normal search for `/\s\{2}$` if will find 2 spaces at the end of the line, even if there are additional preceding spaces. And the syntax match still matches if other characters proceed 2 trailing spaces, but not if the proceeding characters are spaces.
  • Why doesn't my syntax match work if there are proceeding spaces? How can I match 2 trailing spaces on a line even if there are additional spaces before it?
  • I'm using the following syntax match to conceal 2 spaces at the end of a line with a special character.
  • ```vim
  • syntax match Normal '\s\{2}$' conceal cchar=⏎
  • ```
  • A line with two spaces at the end of it would display like this:
  • ```none
  • some line with two trailing spaces⏎
  • ```
  • However, if there are more than two spaces I don't get the special character. I would expect that this would still match on the last two spaces. For example:
  • ```none
  • a line with 4 trailing spaces ⏎
  • ```
  • Instead, it shows all 4 spaces with no special character.
  • If I do a normal search for `/\s\{2}$`, it will find 2 spaces at the end of the line, even if there are additional preceding spaces. Whereas the `syntax match` still matches if other characters proceed 2 trailing spaces, but not if the proceeding characters are spaces.
  • Why doesn't my syntax match work if there are proceeding spaces? How can I match 2 trailing spaces on a line, even if there are additional spaces before it?
#1: Initial revision by user avatar rcmosher‭ · 2024-05-22T17:07:25Z (6 months ago)
Syntax match any 2 spaces at end of line
I'm using the following syntax match to conceal 2 spaces at the end of a line with a special character.

`syntax match Normal '\s\{2}$' conceal cchar=⏎`

A line with two spaces at the end of it would display like this:

`some line with two trailing spaces⏎`

However, if there are more than two spaces I don't get the special character. I would expect that this would still match on the last two spaces. For example:

`a line with 4 trailing spaces  ⏎`

Instead it shows all 4 spaces with no special character.

If I do a normal search for `/\s\{2}$` if will find 2 spaces at the end of the line, even if there are additional preceding spaces. And the syntax match still matches if other characters proceed 2 trailing spaces, but not if the proceeding characters are spaces.

Why doesn't my syntax match work if there are proceeding spaces? How can I match 2 trailing spaces on a line even if there are additional spaces before it?

vim