0

I am using some preset colorthemes, but it seems that the types Identifier and Comment always use the same color -- which makes my .asm files basically just one color. I tried to change the color of the comments with:

:highlight Comment ctermfg=Blue

and it works when I do it directly in vim, but if I put it in my .vimrc it does not work at all. Similar question here but doesn't work for me.

Just in case, this is my .vimrc:

set tabstop=4
set shiftwidth=2
set autoindent
set expandtab

au InsertEnter * set ignorecase
au InsertLeave * set noignorecase

function! Html()
    r~/.vim/code/html.txt
endfunction

map <F6> :tabp<CR>
map <F8> :tabn<CR>
map <F7> :tabe<Space>

" Disable expandtab for Makefiles
let _curfile = expand("%:t")
if _curfile =~ "Makefile" || _curfile =~ "makefile" || _curfile =~ ".*\.mk"
set noexpandtab
else
set expandtab
endif

syntax on
highlight Comment ctermfg=Blue

With or without syntax on there's no effect.

I suspect something is changing the colors and overriding the effect of my .vimrc command, but I don't know what.

  • What is the output of :verbose hi comment – Maxim Kim May 21 at 10:45
  • It seems that it's being overwriten: Comment xxx term=bold ctermfg=14 guifg=#80a0ff Last set from /usr/share/vim/vim80/syntax/syncolor.vim – Xito Dev May 21 at 10:54
  • What is weird is that the color specified in that file for ctermfg is different than what is actually visible. – Xito Dev May 21 at 11:11
  • syncolor.vim is loaded when you do syntax on. And it just resets colors to vim defaults. Try change highlight to highlight! ... – Maxim Kim May 21 at 11:20
  • My bad, this questions seemed familiar to me. I already answered similar one: vi.stackexchange.com/questions/22840/… – Maxim Kim May 21 at 11:23
0

I can't see you use any colorschemes so

:highlight Comment ctermfg=Blue

at the end of your vimrc should work.

Note though, if you use colorscheme, then your highlight would be overridden.

It is possible to do the following:

augroup colorscheme_change | au!
    au ColorScheme * :hi Comment ctermfg=blue
augroup end

Which defines autocommand group and an autocommand inside this group that upon colorscheme change runs your highlight comment command.

UPDATE

Check Comment highlight group does not work without reloading .vimrc

Try adding:

colorscheme default
highlight Comment ctermfg=Blue

to your vimrc.

| improve this answer | |
  • Hi, I set the colorscheme via the terminal itself (xfce4-terminal), so I think maybe it does not affect vim directly? The command didn't work. – Xito Dev May 21 at 10:58
  • So you don't set a colorscheme in vim. – Maxim Kim May 21 at 11:18
  • see updated answer – Maxim Kim May 21 at 11:27
  • Wonderful! It worked perfectly. Thank you so much! My life just got 20% easier. – Xito Dev May 21 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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