On 2009-03-20, Tony Mechelynck wrote:
> On 15/03/09 20:05, adam99 wrote:
> >
> >
> > I tried bang(!) but it runs in the place that I started the gvim, not in the
> > directory of the file...
> >
> > adam99 wrote:
> >>
> >> I am working with several files at the same time. I would like to compile
> >> files in the directory of the file I make a change.
> >>
> >> Is there way to run a shell command in the directory of the file?
> >>
> >> Thanks
> >> Adam
> >>
> >
> 
> It may depend on your shell and/or on your OS
> 
> On any platform, you could do
> 
>       :lcd %:p:h
>       :!somecommand arg1 arg2
> 
> On Linux or Cygwin, where I use bash, I could also do
> 
>       :!(cd %:p:h ; somecommand arg1 arg2)
> 
> to avoid changing the "current directory" seen inside Vim. (Vim replaces 
> %:p:h by the full directory of the current editfile.) I don't know 
> whether other Unix shells accept the same () construct.

The :! command is already run in a subshell so you don't even need
the (); this works as well:

        :!cd %:p:h ; somecommand arg1 arg2

Regards,
Gary



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to