[英]Vim requires .vimrc to be sourced every time when running in tmux
I have made several changes to my .vimrc
file, which includes several vim-plug plugins, some syntax/coloring options and some key mappings. 我对.vimrc
文件进行了几处更改,其中包括一些vim-plug插件,一些语法/颜色选项和一些键映射。
Whenever I open a new Vim session however, not all of these are being applied (most notably coloring and syntax highlighting). 但是,每当我打开一个新的Vim会话时,都不会全部应用(最显着的是着色和语法突出显示)。 If I run :so ~/.vimrc
the file gets sourced and the changes apply immediately. 如果我运行:so ~/.vimrc
该文件将作为源文件并立即应用更改。 Obiously I don't want to have to do this every time I start vim. 显然,我不想每次启动vim都必须这样做。
Why are these changes not being applied automatically? 为什么这些更改没有自动应用? (This is after a complete restart and new terminal/vim session). (这是在完全重新启动和新的终端/ vim会话之后)。
Update 更新
I've discovered this is related to tmux . 我发现这与tmux有关。 When I run vim
straight from terminal, .vimrc
is applied as expected. 当我直接从终端运行vim
, .vimrc
如预期般被应用。 If I run vim
from inside a tmux
session, then I have to manually source the file every time. 如果我在tmux
会话中运行vim
,则每次都必须手动获取文件。
Any ideas how to solve this? 任何想法如何解决这个问题?
~/.vimrc
contents: ~/.vimrc
内容:
" 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
In my case, tmux was overriding the TERM
value until .vimrc
was sourced. 在我的情况下,tmux会覆盖TERM
值,直到获得.vimrc
为止。
Running echo $TERM
in a regular shell gave xterm-256color
, whereas running it in tmux gave screen
. 在常规shell中运行echo $TERM
得到xterm-256color
,而在tmux中运行可以得到screen
。
The solution was to explicitly export the desired TERM
value: 解决方案是显式导出所需的TERM
值:
export TERM="xterm-256color"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.