Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7779709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:42:25+00:00 2026-06-01T18:42:25+00:00

In a vim syntax file I want to name one match foo followed by

  • 0

In a vim syntax file I want to

  • name one match foo followed by bar
  • and another bar that follows foo

And have them both work.

Here is what I have so far

 syn match myFoo /foo\zebar/ display

 syn match myBar /foo\zsbar/ display

When I do that it only matches the latter one.
I cant get both foo and bar to match.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:42:27+00:00Added an answer on June 1, 2026 at 6:42 pm

    Try this:

    syn match myFoo /foo/ contained
    syn match myBar /bar/ contained
    syn match myFooBar /foobar/ contains=myFoo,myBar
    

    I’ve confirmed that it works. I have Vim coloring foobar where the foo is one color and bar is a different color. And this only happens if they are together as foobar; otherwise they are not colorized. I assigned them to different categories like this:

    hi def link myFoo Keyword
    hi def link myBar Type
    

    You probably have this covered already.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody know how to edit a syntax file for VIM so that keywords
I have a long code file with syntax folding in Vim. I know how
I'd like to implement a syntax file for vim that hides certain characters in
Has anyone else found VIM's syntax highlighting of Javascript sub-optimal? I'm finding that sometimes
I'm trying to write some matching rules in a Vim syntax file to highlight
this is the file: https://github.com/mozilla/rust/blob/master/src/etc/vim/syntax/rust.vim this is for rust [a new language from Mozilla]
Has anyone created a vim syntax file for the go language?
I'm trying to patch up a new vim syntax file for some custom format
My syntax -highlighting is broken for a file which Type is conf as follows:
I'm trying to create a syntax file and I want to create some keyword

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.