0

While highlight group in .vimrc highlights patterns just fine, highlight groups in .vim/after/ftplugin folder does not seem to do anything. Is it normal?

1 Answer 1

1

It is normal, you are not using the correct directory. See :h mysyntaxfile-add:

If you are mostly satisfied with an existing syntax file, but would like to
add a few items or change the highlighting, follow these steps:

1. Create your user directory from 'runtimepath', see above.

2. Create a directory in there called "after/syntax".  For Unix: >
    mkdir ~/.config/nvim/after
    mkdir ~/.config/nvim/after/syntax

3. Write a Vim script that contains the commands you want to use.  For
   example, to change the colors for the C syntax: >
    highlight cComment ctermfg=Green guifg=Green

4. Write that file in the "after/syntax" directory.  Use the name of the
   syntax, with ".vim" added.  For our C syntax: >
    :w ~/.config/nvim/after/syntax/c.vim

That's it.  The next time you edit a C file the Comment color will be
different.  You don't even have to restart Vim.

See :h mysyntaxfile-replace if you want to completely replace an existing syntax file.

2
  • Ah, I see. Thanks. Didn't understand where to look in the help file. Related question (don't want to ask a separate question for this): Is there a simple way to toggle a highlighing group? Couldn't find anything in the help file.
    – mahbubweb
    Commented Jun 2, 2020 at 16:17
  • These highlights will go away if I happen to source .vimrc again on a file, right? That's also normal?
    – mahbubweb
    Commented Jun 2, 2020 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.