I am running an instance of Vim in a Docker container, with configuration mostly taken from here (up untill " Build debug and release targets...)

As you can see on the pic, clangd-completer works correctly, as well as nerdtree and tagbar.

However, I don't seem to have any syntax highlighting in the main window (This is c++). I do not know Vim enough to understand what's wrong... (Also, I plan to use Vim with Docker only, if that's of any importance)

Any help?

EDIT: :set term returns term=xterm-256color and :set t_Co returns t_Co=256. I have pushed a github repo with the Dockerfile and related Vim config files. https://github.com/gantsevdenis/vim-ide-cpp-tumbleweed

enter image description here

  • Welcome to Vi and Vim! Check if you have 256 colors enabled, if :set t_Co? returns 16 or less that might be the problem... Also check whether using :set termguicolors helps to fix the issue.
    – filbranden
    Apr 25, 2021 at 21:07
  • Also, is syntax and/or filetype detection on?
    – D. Ben Knoble
    Apr 25, 2021 at 21:18
  • @filbranden :set t_Co returns 8. :set termguicolors doesn't have any effect
    – dgan
    Apr 25, 2021 at 23:46
  • Does :set t_Co=256 help fix the issue? What does :set term? return? Can you please edit the question to include your additional findings?
    – filbranden
    Apr 26, 2021 at 2:26
  • @filbranden That didn't to anything neither.. I have updated the question with a link to github repo (I have added ENV=xterm-256color variable, but that didn't help)
    – dgan
    Apr 26, 2021 at 17:11

1 Answer 1


For me, the problem was that my .conf file was in a file path that vim's filetype.vim did not expect. I was able to get automatic syntax highlighting to work in vim 80 by editing the filetype.vim file in the following way.

sudo vi /usr/share/vim/vim80/filetype.vim

Find a line that ends with setf apache.

" Apache config file
au BufNewFile,BufRead .htaccess,*/etc/httpd/*.conf       setf apache

I opted to use Apache syntax highlighting for any .conf file, no matter its file path, by adding ,*.conf to the list of paths on that line, like this:

" Apache config file
au BufNewFile,BufRead .htaccess,*/etc/httpd/*.conf,*.conf       setf apache
  • 2
    Welcome to Vi and Vim! You don't need to modify the filetypes.vim in the Vim runtimes directory... (The modification will get clobbered if/when the Vim package is upgraded.) Instead, you can create a file ~/.vim/ftdetect/apache.vim with the single line au BufNewFile,BufRead *.conf set filetype=apache for your override.
    – filbranden
    Dec 31, 2021 at 1:28
  • @filbranden - I like your suggestion but it didn't work to automatically syntax highlight my .conf file. I logged out and back in, too. Dec 31, 2021 at 2:12
  • Ah, actually you need au BufNewFile,BufRead *.conf set filetype=apache for an override. (set filetype=... takes precedence over setf, so you should use it in an override to ensure it will be the one to take effect even though there are other existing rules for the same filename pattern.)
    – filbranden
    Dec 31, 2021 at 4:05
  • 1
    Ah Sorry again, I got the extensions mixed up! The file in ftdetect/ should have a *.vim extension. I edited my first comment to fix that up. Would you give that one last try?
    – filbranden
    Dec 31, 2021 at 16:39
  • 1
    That worked! Thank you, and Happy New Year! Jan 1, 2022 at 18:05

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.