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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:28:44+00:00 2026-05-14T02:28:44+00:00

How I can keep all the current formatting for a file type but add

  • 0

How I can keep all the current formatting for a file type but add functionality.

I would like to highlight colors in .vim files so that each color is highlighted how the terminal will resolve it.

I created a vim.vim file containing:

syn keyword yellow yellow containedin=All                                                    
highlight yellow ctermfg=yellow                                                              
                                                                                             
syn keyword red red containedin=all                                                          
highlight red ctermfg=red                                                                    
                                                                                        

and put it into ~/.vim/after/syntax/vim.vim

As suggested here.

This has no effect.


Update

In fact I was mistaken when I said my changes had no effect. If you type yellow by itself on a line it will be highlighted yellow. Unfortunately this does not solve my problem.

I added the F3 functionality described by Al.

When I f3 over yellow (in the context ctermfg=yellow) it returns:

hi<vimHiCtermColor> trans<vimHiCtermColor> lo<vimHiCtermColor> FG:-1 BG:-1

Then :syn list vimHiCtermColor returns:

--- Syntax items ---
vimHiCtermColor xxx contained lightmagenta darkgray lightgrey darkgrey lightgreen lightgray darkmagenta gray white red grey darkred brown darkblue darkgreen lightblue yellow cyan
                   contained lightcyan lightred black blue green magenta darkcyan darkyellow

I checked :syn list darkgray (something I have not defined) to see if it exists:

--- Syntax items ---
E28: No such highlight group name: darkgray
Hit ENTER or type command to continue

Where should I go from here?

  • 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-14T02:28:45+00:00Added an answer on May 14, 2026 at 2:28 am

    Solution

    Here’s a direct answer for coloring just the word yellow.

    syn cluster vimHiCtermColors contains=vimHiCtermColorYellow
    syn keyword vimHiCtermColorYellow yellow contained
    
    syn match  vimHiCtermFgBg   contained   "\ccterm[fb]g="he=e-1   nextgroup=vimNumber,vimHiCtermColor,@vimHiCtermColors,vimFgBgAttrib,vimHiCtermError
    
    highlight vimHiCtermColorYellow ctermfg=yellow
    

    And here’s a solution for coloring all the color terminal names. They are only colored in the terminal (not the GUI), and other attributes (256-color terminal, GUI colors, attributes such as bold) are not highlighted at all. To extend this further, you’d probably want some sort of script to iterate over all the possible values.

    syn cluster vimHiCtermColors contains=vimHiCtermColorBlack,vimHiCtermColorBlue,vimHiCtermColorBrown,vimHiCtermColorCyan,vimHiCtermColorDarkBlue,vimHiCtermColorDarkcyan,vimHiCtermColorDarkgray,vimHiCtermColorDarkgreen,vimHiCtermColorDarkgrey,vimHiCtermColorDarkmagenta,vimHiCtermColorDarkred,vimHiCtermColorDarkyellow,vimHiCtermColorGray,vimHiCtermColorGreen,vimHiCtermColorGrey,vimHiCtermColorLightblue,vimHiCtermColorLightcyan,vimHiCtermColorLightgray,vimHiCtermColorLightgreen,vimHiCtermColorLightgrey,vimHiCtermColorLightmagenta,vimHiCtermColorLightred,vimHiCtermColorMagenta,vimHiCtermColorRed,vimHiCtermColorWhite,vimHiCtermColorYellow
    
    syn keyword vimHiCtermColorBlack black contained
    syn keyword vimHiCtermColorBlue blue contained
    syn keyword vimHiCtermColorBrown brown contained
    syn keyword vimHiCtermColorCyan cyan contained
    syn keyword vimHiCtermColorDarkBlue darkBlue contained
    syn keyword vimHiCtermColorDarkcyan darkcyan contained
    syn keyword vimHiCtermColorDarkgray darkgray contained
    syn keyword vimHiCtermColorDarkgreen darkgreen contained
    syn keyword vimHiCtermColorDarkgrey darkgrey contained
    syn keyword vimHiCtermColorDarkmagenta darkmagenta contained
    syn keyword vimHiCtermColorDarkred darkred contained
    syn keyword vimHiCtermColorDarkyellow darkyellow contained
    syn keyword vimHiCtermColorGray gray contained
    syn keyword vimHiCtermColorGreen green contained
    syn keyword vimHiCtermColorGrey grey contained
    syn keyword vimHiCtermColorLightblue lightblue contained
    syn keyword vimHiCtermColorLightcyan lightcyan contained
    syn keyword vimHiCtermColorLightgray lightgray contained
    syn keyword vimHiCtermColorLightgreen lightgreen contained
    syn keyword vimHiCtermColorLightgrey lightgrey contained
    syn keyword vimHiCtermColorLightmagenta lightmagenta contained
    syn keyword vimHiCtermColorLightred lightred contained
    syn keyword vimHiCtermColorMagenta magenta contained
    syn keyword vimHiCtermColorRed red contained
    syn keyword vimHiCtermColorWhite white contained
    syn keyword vimHiCtermColorYellow yellow contained
    
    syn match  vimHiCtermFgBg   contained   "\ccterm[fb]g="he=e-1   nextgroup=vimNumber,@vimHiCtermColors,vimFgBgAttrib,vimHiCtermError
    
    highlight vimHiCtermColorBlack ctermfg=black
    highlight vimHiCtermColorBlue ctermfg=blue
    highlight vimHiCtermColorBrown ctermfg=brown
    highlight vimHiCtermColorCyan ctermfg=cyan
    highlight vimHiCtermColorDarkBlue ctermfg=darkBlue
    highlight vimHiCtermColorDarkcyan ctermfg=darkcyan
    highlight vimHiCtermColorDarkgray ctermfg=darkgray
    highlight vimHiCtermColorDarkgreen ctermfg=darkgreen
    highlight vimHiCtermColorDarkgrey ctermfg=darkgrey
    highlight vimHiCtermColorDarkmagenta ctermfg=darkmagenta
    highlight vimHiCtermColorDarkred ctermfg=darkred
    highlight vimHiCtermColorDarkyellow ctermfg=darkyellow
    highlight vimHiCtermColorGray ctermfg=gray
    highlight vimHiCtermColorGreen ctermfg=green
    highlight vimHiCtermColorGrey ctermfg=grey
    highlight vimHiCtermColorLightblue ctermfg=lightblue
    highlight vimHiCtermColorLightcyan ctermfg=lightcyan
    highlight vimHiCtermColorLightgray ctermfg=lightgray
    highlight vimHiCtermColorLightgreen ctermfg=lightgreen
    highlight vimHiCtermColorLightgrey ctermfg=lightgrey
    highlight vimHiCtermColorLightmagenta ctermfg=lightmagenta
    highlight vimHiCtermColorLightred ctermfg=lightred
    highlight vimHiCtermColorMagenta ctermfg=magenta
    highlight vimHiCtermColorRed ctermfg=red
    highlight vimHiCtermColorWhite ctermfg=white
    highlight vimHiCtermColorYellow ctermfg=yellow
    

    Explanation

    If you look in colors/vim.vim and search for cterm, you’ll see a line

    syn match  vimHiCtermFgBg   contained   "\ccterm[fb]g="he=e-1   nextgroup=vimNumber,vimHiCtermColor,vimFgBgAttrib,vimHiCtermError
    

    This says that, when ctermfg= or ctermbg= is encountered, highlight the next word as vimNumber, vimHiCtermColor, vimFgBgAttrib, or vimHiCtermError. Looking at vimHiCtermColor (a few lines above), we see

    syn keyword vimHiCtermColor contained   black blue brown cyan darkBlue darkcyan darkgray darkgreen darkgrey darkmagenta darkred darkyellow gray green grey lightblue lightcyan lightgray lightgreen lightgrey lightmagenta lightred magenta red white yellow
    

    This lists all of the color terminal names, and they are highlighted as keywords with the same syntax group. So, instead of highlighting them all together, we can highlight them separately. The four lines of the first solution above describe the steps:

    1. Create a new cluster, @vimHiCtermColors containing each of the groups in step 2.
    2. Add a new keyword for each color value.
    3. Modify the vimHiCtermFgBg definition to use @vimHiCtermColors instead of vimHiCtermColor.
    4. Highlight each keyword as you wish.

    The reason why what you tried did not work is twofold. First, the syntax groups specified in the nextgroup are preferred over general groups (your yellow group, in particular). But, you may say, “What about containedin=ALL?” This is the second point. Keywords are individual units and cannot contain anything else. The original vimHiCtermColor group was all keywords, so your containedin=ALL could not override it. If vimHiCtermColor had been a match instead of a keyword, it may have worked.

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

Sidebar

Related Questions

I have implemented VirtualPathProvider class so I can keep all my views in the
I'm working on an HTML class in PHP, so that we can keep all
I'm using this vim plugin for coffeescript and I want to keep all my
I wonder if I can keep ido from not remembering my history and only
Is there any way with subversion or any other VCS that i can keep
How can you keep track of time in a simple embedded system, given that
I've reached a point were I can't keep procrastinating the writing of the graphics
When I call a Powershell script, how can I keep the called script from
How can I make a keep alive HTTP request using Python's urllib2?
Can anyone provide some real examples as to how best to keep script files

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.