Search code examples
vimhomebrewzshtmux

tmux Using the Wrong Version of Vim


I installed Vim and tmux using brew install vim and brew install tmux, and when running vim --version outside tmux with zsh as the default shell I get this:

macOS version - arm64
Included patches: 1-3550
Compiled by Homebrew

which is what I want. However, when running vim --version in a tmux session, I get this:

macOS version
Included patches: 1-2029
Compiled by [email protected]

which is not what I want.

I was thinking that this could have something to do with the arm64 architecture of my processor. I installed Homebrew with this terminal command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

I would appreciate any feedback. Thanks!


Solution

  • Solved! I noticed that when typing type -a vim outside a tmux session I got:

    vim is /opt/homebrew/bin/vim
    vim is /usr/bin/vim
    

    But, when typing type -a vim inside a tmux session I got:

    vim is /usr/bin/vim
    vim is /opt/homebrew/bin/vim
    

    which means that, for some unknown reason, the paths to the different versions of vim got swapped in a tmux session.

    I solved this by putting the following in my .zshrc:

    alias vi=/opt/homebrew/bin/vim
    alias vim=/opt/homebrew/bin/vim
    

    This works because it forces the vi and vim commands to use the version of vim found in the path I specified in the .zshrc.

    I hope this helps anyone who has the same problem.