Wednesday, June 1, 2011

Re: Different working directories in different tabs

On 2011-05-31, Martin Lundberg wrote:
> On Tuesday, May 31, 2011 2:55:40 PM UTC+2, Christian Brabandt wrote:
>
>
> :h :lcd
>
> regards,
> Christian
>
> Hi Christian. To my understanding that is not what I'm talking about. The :lcd
> command changes it for the current window. I'm talking about creating a new tab
> and changing the working directory using :cd. It changes the cwd for that tab
> only (you can even see the filenames of the other tabs changing on the tabs).
> If you then change back to another tab it's cwd has not changed.

There are two commands that change the working directory: :cd,
which is global, and :lcd, which is window-local. There is no
change-directory command whose scope is a tab.

That said, you could use the TabEnter autocommand event and a
tab-local variable to :cd to the working directory you define for
each tab. That is, in each tab you could execute

:let t:wd = "some/directory"

and in your ~/.vimrc you could have an autocommand something like
this:

au TabEnter * if exists("t:wd") | exe "cd" t:wd | endif

See

:help TabEnter
:help t:var

Regards,
Gary

--
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:

Post a Comment