6

I have made several changes to my .vimrc file, which includes several vim-plug plugins, some syntax/coloring options and some key mappings.

Whenever I open a new Vim session however, not all of these are being applied (most notably coloring and syntax highlighting). If I run :so ~/.vimrc the file gets sourced and the changes apply immediately. Obiously I don't want to have to do this every time I start vim.

Why are these changes not being applied automatically? (This is after a complete restart and new terminal/vim session).

Update
I've discovered this is related to tmux. When I run vim straight from terminal, .vimrc is applied as expected. If I run vim from inside a tmux session, then I have to manually source the file every time.

Any ideas how to solve this?

~/.vimrc contents:

" PLUGINS - see vim-plug
call plug#begin()
 Plug 'crusoexia/vim-monokai'
 Plug 'pangloss/vim-javascript'
 Plug 'crusoexia/vim-javascript-lib'
call plug#end()

" Enable Monokai colors
syntax on
colorscheme monokai
set t_Co=256

" Easy tab movement with keys 1|2
nmap 1 :tabp <enter>
nmap 2 :tabn <enter>

" Line Numbers
set number

" 2 space tabs
set tabstop=8 softtabstop=2 expandtab shiftwidth=2 smarttab
duncanhall
  • 11,035
  • 5
  • 54
  • 86

1 Answers1

6

In my case, tmux was overriding the TERM value until .vimrc was sourced.

Running echo $TERM in a regular shell gave xterm-256color, whereas running it in tmux gave screen.

The solution was to explicitly export the desired TERM value:

export TERM="xterm-256color"

duncanhall
  • 11,035
  • 5
  • 54
  • 86
  • Please forgive my ignorance, but where should I put the line `export TERM...`? Also, it is recommended not to change TERM: https://github.com/tmux/tmux/wiki/FAQ – Yankee Jul 24 '19 at 14:26
  • @Yankee `export TERM...` is a generic command that sets the `TERM` environment variable. Where you put it depends on your setup, but likely options are `~/.bashrc`, `~/.profile` or `~/.zshrc` etc – duncanhall Jul 25 '19 at 09:14