I'm just trying to get conceal working, so I've created a simple test case. I have a clean .vimrc file with only the following lines:

set conceallevel=2
syn match Conceal /syn/ conceal cchar=+

However, when I initially open this file in vim, the "syn" is not replaced with a "+" (it doesn't matter which line the cursor is on). But when I do :source % to reload this .vimrc, it starts working, replacing the occurrence "syn" with "+".

I have verified that this .vimrc does work when vim is initially opened for other things. For example, given the following .vimrc, the word "hi" is highlighted in red, while the word "syn" remains unconcealed until I type :source %.

set conceallevel=2
syn match Conceal /syn/ conceal cchar=+
hi Test ctermfg=red
match Test /hi/

What gives?

  • with your initial vimrc (when it is not working), what does :verbose :set conceallevel? output? Commented Mar 26, 2019 at 16:31
  • It says: conceallevel=2 Last set from ~/.vimrc Commented Mar 26, 2019 at 16:35

1 Answer 1


First regarding your second example: The match Test /hi/ is not syntax highlighting, but "match highlighting". This are two different things. The hi is still highlighted after you executed :syntax off.

Now the initial problem:

Your initial syntax-conceal definition is deleted in the process of loading the syntax definition needed for your .vimrc. While loading the syntax, Vim first removes all syntax definition active in the current buffer and replaces them with the filetype-specific definitions.

When you source the .vimrc again, the syntax-conceal is defined again and works.

If you want to conceal the word syn in vim files, create the file $HOME/.vim/after/syntax/vim.vim ($HOME/vimfiles/after/syntax/vim.vim on Windows) and put your definition in it. The files from the after directory are loaded after Vim loaded its default configuration. So Vim first loads the default Vim syntax and after that loads your $HOME/.vim/after/syntax/vim.vim.

See :help mysyntaxfile-add.

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.