Loading ...
Sorry, an error occurred while loading the content.

Re: changing default directory

Expand Messages
  • Benji Fisher
    ... There are differences between environment variables and normal ones. On my W95 system (where I am now) I can do ... So change to ... else | exe cd
    Message 1 of 2 , May 23, 2000
    • 0 Attachment
      Eugene Lee wrote:
      >
      > 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. :)

      There are differences between environment variables and normal
      ones. On my W95 system (where I am now) I can do

      :let VIM = $VIM
      :cd $VIM
      :cd $VIM " error!
      :execute "cd " . VIM
      :echo $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
    Your message has been successfully submitted and would be delivered to recipients shortly.