我想我的终端当前目录跟随我的VIM之一。
例:
在TERMINAL:
> pwd => /Users/rege > vim然后在VIM
:cd /Users/rege/project <Ctrl-z>(for suspend)在终端
> pwd => /Users/rege/project我正在使用MacOS,zsh,tmux。
我需要这个,因为当我试图在VIM中使用标签时,标签是从我的终端目录检查项目而不是vim。
因此,当我更改VIM当前目录时,我总是需要更改终端当前目录。
I would like to my terminal current directory follows my VIM one.
Example:
In TERMINAL:
> pwd => /Users/rege > vimThen in VIM
:cd /Users/rege/project <Ctrl-z>(for suspend)In terminal
> pwd => /Users/rege/projectI`m using MacOS, zsh, tmux.
I need this because when Im trying to use tags in VIM, tags are check in project from my terminal directory not vim one.
So I need to change terminal current directory always when I change VIM current directory.
最满意答案
暂停Vim后,你在shell中发出什么样的命令? 不是Vim的:!command不够?
使用set autochdir ,当您从一个文件跳转到set autochdir ,Vim的当前目录会跟随您。 使用此设置,简单:!ctags -R . 将始终在当前文件的目录中创建一个tags文件。
另一个有用的设置是set tags=./tags,tags;$HOME告诉Vim在当前文件的目录中查找tags文件,然后在“当前目录”中向上和向上查找,直到它到达~/ 。 您可以修改端点以满足您的需求。 这允许您在编辑属于项目的任何文件时在项目的根目录中使用tags 。
所以,基本上,你可以在不离开Vim的情况下走很长的路。
如果你真的需要回到shell发出命令, :shell (或:sh )用Vim的当前目录启动一个新的shell。 当你完成后,你只需要$ exit以回到Vim:
$ pwd /home/romainl $ vim :cd Projects :sh $ pwd /home/romainl/Projects $ exitWhat kind of command do you issue in your shell after you suspend Vim? Isn't Vim's :!command enough?
With set autochdir, Vim's current directory follows you as you jump from file to file. With this setting, a simple :!ctags -R . will always create a tags file in the directory of the current file.
Another useful setting is set tags=./tags,tags;$HOME which tells Vim to look for a tags file in the directory of the current file, then in the "current directory" and up and up until it reaches your ~/. You might modify the endpoint to suit your needs. This allows you to use a tags at the root of your project while editing any file belonging to the project.
So, basically, you can go a long way without leaving Vim at all.
If you really need to go back to the shell to issue your commands, :shell (or :sh) launchs a new shell with Vim's current directory. When you are done, you only have to $ exit to go back to Vim:
$ pwd /home/romainl $ vim :cd Projects :sh $ pwd /home/romainl/Projects $ exit更多推荐
发布评论