+ -
当前位置:首页 → 问答吧 → vim autocmd

vim autocmd

时间:2011-12-16

来源:互联网

fedora 系统,我用vim编辑器更改了~/.bashrc,但是每次更改完了都得source ~/.bashrc,很繁琐,怎么在.vimrc中添加autocmd使得每当保存~/.bashrc时,都自动执行source ~/.bashrc

作者: wangmm2008   发布时间: 2011-12-16

没有人知道吗?

作者: wangmm2008   发布时间: 2011-12-17

你想要的是不是这个功能呢?
http://stackoverflow.com/questions/1694599/how-do-i-get-vims-sh-command-to-source-my-bashrc
只要在.vimrc中加上一句话就可以了

作者: askandstudy   发布时间: 2011-12-17

引用 2 楼 askandstudy 的回复:

你想要的是不是这个功能呢?
http://stackoverflow.com/questions/1694599/how-do-i-get-vims-sh-command-to-source-my-bashrc
只要在.vimrc中加上一句话就可以了

set shell=bash\ --login没有作用
cmap sh<CR> !bash --login<CR>可以实现,但是太麻烦还是需要我自己执行

我想该的是
autocmd BufWritePre ~/.bashrc exec source ~/.bashrc
但是这样改有错误
Error detected while processing BufWrite Auto commands for "/home/wangmm/.bashrc
":
E121: Undefined variable: source
不知道哪里的错误

作者: wangmm2008   发布时间: 2011-12-17