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 6682241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:40:58+00:00 2026-05-26T04:40:58+00:00

I try to compact some chord files and then need to highlight some stuff

  • 0

I try to compact some chord files and then need to highlight some stuff so it is more visual. This syntax is where chord is followed by a comma then a number showing how many beats, and all surrounded in curly brackets. Here is the example from a classic rock song you might have heard:

{Dm,4}Don't cry, don't {C/D,4}raise your eye
It's {Bb/D,2}on-ly {Am,2} teen-age {Dm,4hold}waste-land

I simply want to make the chord names one color, and the time notation another color… In a nutshell that’s everything between { and next , as one color then up to the next } as a second color. Maybe the brackets should be another color too. I suck at regular expressions but this forum can point me in right direction to eventually master them I hope.

  • 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-05-26T04:40:59+00:00Added an answer on May 26, 2026 at 4:40 am

    Here is a very simple version that will just highlight the whole {...} blocks. Put the following in ${HOME}/.vim/syntax/rock.vim:

    if exists("b:current_syntax")
        finish
    endif
    
    syntax match rockNotation      "{[^}]*}"
    
    highlight link rockNotation    String
    

    And the following in ${HOME}/.vim/ftdetect/rock.vim:

    autocmd BufRead,BufNewFile *.rock set filetype=rock
    

    Now whenever you open a .rock file, the chords should be highlighted. (If detection doesn’t work, try to set :set filetype=rock manually, see if it changes something.) Note that if you edited these files from Vim, you may need to restart it for the effects to apply.

    Here is a longer version, where chords and time indications are highlighted in different colors:

    if exists("b:current_syntax")
        finish
    endif
    
    syntax clear
    syntax case match
    
    setlocal iskeyword+=#                                                                         
    setlocal iskeyword+=-
    setlocal iskeyword+=+
    
    syntax match rockChord /\<[A-G]\(b\|#\)\=\(m\|-\|dim\|+\|aug\|7\|m7\|Maj7\|m7b5\)\=\(\/[A-G]\(b\|#\)\=\)\=\>/ contained
    syntax match rockDuration /[1-9][0-9]*\(hold\|mute\)\=/ contained
    
    syntax region rockAnnotRegion start=/{/ end=/}/ contains=rockChord,rockDuration
    
    highlight link rockChord          Type
    highlight link rockDuration       Constant
    highlight link rockAnnotRegion    Delimiter
    

    As you can see, my regexp for chords got a little wild. It supports things like A#m7b5/Db, which of course makes little sense (and sounds horrible), but you get the idea.

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

Sidebar

Related Questions

I try to use SQL Server Compact Edition with Entity Framework in Visual Studio
I try to import sql script, generated with Server Management Studio, into SQL Compact
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
I've just done a clean install of Visual C# 2008 SP1, Sql Compact 3.5
Edit: This is done in the Compact Framework, I don't have access to WebClient
I'm writing a compact framework 3.5 application for a windows mobile device. In this
I am trying to validate against a RelaxNG compact syntax file using Nokogiri. Nokogiri
Compact description I'm having a problem to find out what's wrong, for some obscure
Hey, I am using iBATIS with SQL Server Compact Edition 3.5 and try to
I try to find a tutorial or some documentation to find how create PieChart

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.