gpt4 book ai didi

bash - 从 Vim 中执行 Bash 函数 - 我该怎么做?

转载 作者:行者123 更新时间:2023-11-29 08:55:20 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Commands executed from vim are not recognizing bash command aliases

我的 ~/.bashrc 文件(在我的 Ubunut 盒子上)中有以下函数

# convert tex to pdf, no bib 
function t2p {
latex $1 && latex $1 && dvips $1 -o $1.ps && ps2pdf $1.ps && rm -f $1.dvi }

# convert tex to pdf, with bib
function tb2p {
latex $1 && bibtex $1 && latex $1 && latex $1 && dvips $1 -o $1.ps && ps2pdf $1.ps && rm -f $1.dvi }

例如,要将 tex 文件 f.tex 转换为 pdf 文件并以正确的顺序对其进行 bibtex,我调用 tb2p f。如果我在 Bash 终端中,这非常有效。然而,要从 Vim 中进入 Bash 提示符,我实际上必须先执行命令 :sh

为了简化上述过程,我尝试通过 :!t2p f 在 Vim 中执行函数 t2ptb2p。然后 Vim 告诉我它找不到函数 t2p。我做了一些谷歌搜索,读到我应该将这些函数放入文件 /etc/bash.bashrc 以使它们对 Vim 可见。不幸的是,这对我来说不起作用。 Vim 仍然不知道这个函数。

最终,我希望能够使用键盘快捷键从 Vim 中调用我的函数。因此,我的问题如下:

  1. 如何让 Vim 知道 ~/.bashrc 函数?
  2. 如何在 ~/.vimrc 中为 ~/.bashrc 中的函数设置键盘快捷键?

非常非常感谢。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com