I think Google mail just sent an empty reply from me as well, sorry for spam there.
On Aug 19, 12:53 am, Ben Schmidt <[email protected]> wrote: > On 19/08/11 8:23 AM, John Beckett wrote: > > > What you want is something like this: > > :saveas %:p:h/newname.txt > > Alternatively, you could use one of the many tricks to ensure the > current directory matches the directory of the file in the current > buffer. If you search the Vim tips wiki, I'm sure you'll find a few ways > to do that if you're interested. > > Ben. Thanks for your answers, although I hoped I'd covered them both in my original email to save people suggesting them :) It's useful to know they're the methods people recommend. A recent unrelated thread showed me what's obviously a more correct way to redefine :saveas than my attempts, i.e. remapping :sav to call my custom command. I can't account for not spotting that before (especially since I was already mapping F7 to call it ): Anyway, now I have "All on one line command! -nargs=1 SaveasSamePath exe "sav " . expand("%:p:h") . "/" . expand("<args>") "Remap so I get my command nnoremap :sav :SaveasSamePath "... and so I can still get the original if I need it by typing it in full nnoremap :saveas :saveas Hopefully this won't cause problems even for plugins that assume no mappings and issue the command ":sav" themselves. I haven't been able to make it go wrong myself in defined commands (defining more execute commands to call "sav" works as expected and calls :saveas). The original reason I didn't want to change the working directory whenever I switch to a buffer was because 'autochdir' seemed to cause problems, and also, the help makes it sound (to me) like a very non-standard option. That was a couple of years ago when I looked at this. (This saveas problem doesn't trip me up very often, which is why I can't just remember %:p:h) I did more recently find http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file and my impression was the methods of doing this still might cause problems in some situations; since I don't particularly want to change directory apart from to solve my saveas problem, it seemed better to avoid doing so. But, if this remapping doesn't work out I'll probably look at it again. regards, Geoff -- 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
