I am using vim installed via homebrew:

> which vim

> vim --version
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled May 09 2024 07:15:02)
macOS version - arm64
Included patches: 1-400
Compiled by Homebrew
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
 3rd user vimrc file: "~/.config/vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/opt/homebrew/share/vim"

I recently updated iTerm2 and MacOS:

I am now using iTerm2 build 3.5.0

enter image description here

I am now on MacOS Sonoma 14.5

enter image description here

All of a sudden my ~/.vimrc doesn't seem to be sourcing properly. Notably, when I start vim, my cursorline is underlined. When I execute :source ~/.vimrc, the underline disappears, as expected. Relevant settings in my .vimrc are:

set notermguicolors
set t_Co=16

set cursorlineopt=both
set cursorline

set background=dark
colorscheme default
syntax on

highlight clear CursorLine
highlight clear Todo
highlight signcolumn ctermbg=8
highlight statuslinenc ctermbg=3 ctermfg=8
highlight matchparen ctermbg=1 ctermfg=7
highlight diffchange ctermbg=0
highlight difftext ctermfg=8

Also worth noting that most of my settings seem to load just fine. There are just some minor syntax highlighting changes that happen when I manually source ~/.vimrc (e.g. brackets and parens change color)

Other noteworthy things: these env vars don't seem to be set?

> echo $VIM



Prior to updating, my .vimrc sourced just fine at start up.

Inspecting output from vim -V has me thinking it's to do with who is setting highlights most recently. But still not sure why it's behaving differently than it used to.

Any suggestions on how to debug this? Thanks!

  • Do you have the XDG_CONFIG_HOME environment variable defined (In iTerm what is the result of echo $XDG_CONFIG_HOME) Commented May 23 at 8:24
  • 1
    What is the value of the $HOME environment variable? Commented May 23 at 9:24
  • 2
    $VIM and $VIMRUNTIME are only set in Vim. Do :echo $VIM and :echo $VIMRUNTIME in Vim and add their output to your question, as well as the output of :echo $HOME and :echo $MYVIMRC.
    – romainl
    Commented May 23 at 13:43
  • This probably depends on when you call a :syntax or :colorscheme command.
    – D. Ben Knoble
    Commented May 23 at 16:34
  • 1
    Please don't put "EDIT" markers in the text; restructure the body as necessary to make it one coherent whole. Provide one single minimal vimrc that reproduces the issue: I see two codeblocks, one with cursorline options and one without. Can you edit to make them one example?
    – D. Ben Knoble
    Commented May 28 at 16:58

2 Answers 2


In recent version of Vim the $XDG_CONFIG_HOME environment variable is now supported.

On Unix systems if you have $XDG_CONFIG_HOME defined the first vimrc path considered is now: $XDG_CONFIG_HOME/vim/vimrc

  • What makes you think that environment variable is involved?
    – romainl
    Commented May 23 at 10:53
  • To be honest I have a doubt :-| The OP is about macOS that should not be impacted by the recent XDG support in Vim. But XDG support is a recent addition that impact the search for vimrc file. Commented May 23 at 11:21
  • No. $HOME/.config/vim/vimrc is tried after $HOME/.vimrc and $HOME/.vim/vimrc, and only the first one is sourced anyway.
    – romainl
    Commented May 23 at 13:54

I was able to solve this by setting the iTerm2 terminal reporting type to ansi as opposed to xterm or xterm-256color.

I don't know why set t_Co=16 wouldn't force vim to use 16 colors even if iTerm is xterm-256color but I'll stick with ansi for now.

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.