Vim 忽略别名

von*_*gen 12 vim shell alias ignore

如果我使用类似的东西在 vim 中映射命令

map <f4> :! pdflatex %<cr>
Run Code Online (Sandbox Code Playgroud)

Vim 将忽略我的 pdflatex 别名(类似于 alias pdflatex='pdflatex --temp-dir=something')。有没有可能让vim不忽略它?

aki*_*ira 17

Vim '忽略'你的别名,因为你的 shell 没有“心情”来解析你的.bash_profile/.bashrc(你没有指定,你的别名是在哪里定义的),因为它不是作为登录/交互式 shell 启动的(阅读这里了解更多关于什么时候以及出于什么原因阅读什么)。

因此,您有多种选择:

  1. 将您在pdflatex别名中使用的代码放入脚本中并调用它
  2. vimrc: 'set shell=/bin/bash\ -l', 把你的别名放到 .bash_profile
  3. 将您的 shell 作为交互式/登录 shell 调用: :! bash -l -i -e 'pdflatex .'

  • 登录/非登录对 `~/.bashrc` 没有影响——只有交互/非交互才重要。 (2认同)