Re: changing default directory
- Eugene Lee wrote:
>There are differences between environment variables and normal
> I'm trying to use the autocommands to change my working directory to the
> desktop folder if Vim is invoked without opening an existing file (i.e.
> start up Vim by itself). I'm modified some macros found in macvimrc
> that included with the MacVim distribution.
> let DESKTOP = substitute($VIM,":.*",":Desktop Folder","")
> autocmd VimEnter * if strlen(@%) != 0 | cd %:p:h | else | cd DESKTOP | endif
> So the idea is that if I invoke Vim by opening an existing file, then it
> will cd to the same directory as the existing file. Otherwise, cd to
> the Mac desktop. However, this last part doesn't work, and generates an
> error message:
> Error detected while processing VimEnter Auto commands for "*":
> Command failed
> Any suggestions are appreciated. :)
ones. On my W95 system (where I am now) I can do
:let VIM = $VIM
:cd $VIM " error!
:execute "cd " . VIM
So change to
... else | exe"cd ".DESKTOP ...
and it should work. (This time, I only left in the space that matters.)
HTH --Benji Fisher