cd之后的vim命令 [英] vim command after cd

查看:127
本文介绍了cd之后的vim命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从vim到新目录cd后自动执行命令.例如,我打开gvim并运行:

I want to execute a command automatically after cd'ing to a new directory from within vim. For example, I open gvim and run:

:cd ~/src/player

我现在希望vim自动获取该目录中的文件.

I would like vim at this point to automatically source a file that is in that directory.

这可能吗?

推荐答案

您可以在.vimrc中为其编写别名:

You can write an alias for that in your .vimrc:

command -nargs=1 Mycd call MyCd(<args>)
function MyCd(path)
  cd a:path
  e somefile.ext
endfunction

然后只需键入:

:Mycd /some/path/

这篇关于cd之后的vim命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆