Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
vim内から新しいディレクトリにcdした後、コマンドを自動的に実行したい。たとえば、gvim を開いて実行します。
:cd ~/src/player
この時点で、vim がそのディレクトリにあるファイルを自動的に取得するようにしたいと思います。
これは可能ですか?
そのためのエイリアスを .vimrc に書くことができます:
command -nargs=1 Mycd call MyCd(<args>) function MyCd(path) cd a:path e somefile.ext endfunction
次に、次のように入力します。
:Mycd /some/path/
正確にはあなたが求めているものではありませんが
:au BufEnter、BufFilePost * lc <afile> :h
新しいファイルを開くたびに(たとえば、を使用して:e ~/src/player/README)、ディレクトリを自動的にに変更するようになります~/src/player。複数のバッファを開くと、ローカルバッファを切り替えるディレクトリに移動します。複数のタブを開くと、それぞれのディレクトリに残ります。
:e ~/src/player/README
~/src/player