Tuesday, February 22, 2011

Re: How to open a new tab with relative path in vim

On Feb 22, 3:58 am, coolesting <coolest...@gmail.com> wrote:
> As this topic, i need to open a new tab with relative path when the vim
> running,
> such as the command "tabnew ../abc.php" or "tabnew ./abc.php" ,  that is not
> working.
>
> i have to open it with absolute path every time.
>

Vim has a "current working directory" which you can change with :cd
and echo with :pwd. This is global to the Vim instance, regardless of
where the file is located.

Vim also has a concept of a "local working directory" which you can
change with :lcd and again echo with :pwd. Again, this is regardless
of where the file is located.

I suspect that you expect Vim to treat paths as relative to the file
currently loaded in a buffer, as is true with many other editors. This
is not how Vim works, however there is an option to always set the
working directory to that of the file being edited. Set the
'autochdir' option and you will be able to use paths relative to the
file currently being edited.

Note that 'autochdir' has in the past caused some problems with
plugins. I have not personally noted any plugin problems, but then I
do not use very many plugins.

I have noted some problems with sessions created with this option
turned on and certain plugin windows open (like TagList), however I do
not know whether this is the fault of the plugin or the option; I have
not investigated very far because I rarely use sessions anyway.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: