On Thu, Sep 9, 2010 at 12:58 PM, Gary Johnson <[email protected]> wrote: > On 2010-09-09, lessthanideal wrote: >> I'm using Windows VIM 7.3.2 (the Vim without Cream build) >> >> :saveas puts the new file into the current working directory if >> no path is specified. I want it to default to the directory of >> the original file. >> >> Example, from new VIM session >> :cd c:\test >> :e c:\h.txt " cwd is still c:\test >> :sav h2.txt " I want this to come out as c:\h2.txt but >> " it comes out as c:\test\h2.txt >> >> I could do this by defining my own :Sav command but I'd like it >> to be the default if possible. I considered autochdir but it can >> cause plugin problems. I looked on the Vim Wiki. >> >> I can do it manually by changing directory (:cd) first. I've tried >> to do it by using BufFilePre and BufFilePro to temporarily >> change the current working directory before and after the :saveas >> but it doesn't seem to work - it seems the directory changes (from >> making the autocommands echo the directory at various points), but >> for some reason :saveas doesn't uses the working directory then. >> I don't really understand exactly what goes on though, for one thing >> each event is triggered twice. >> >> I tried with gvim -u NONE -N to turn off conflicts with plugins etc. >> >> Is this an approach that should work? Can anyone suggest how to do >> this, if it's possible? > > It's a little more typing (6 characters), but you could do this: > > :saveas %:p:h/newname
I was looking for a way to do this. I think I was always exiting out of vi, then changing to the directory and reopening the file. Could you explain what the p and h do? % is the current file I believe. Thanks, Ven > > 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 > -- 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
