How to set the path of a file as the current directory of gvim on linux automatically when it is opened ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to set the path of a file as the current directory of gvim on linux automatically when it is opened ?

Lenin Lee
On Windows, when I double click a file and open it using gvim, the path of the file will be set as the current directory of gvim.

But when I do the same thing on linux, the current directory of gvim always is my home directory.

I searched for the question with google, but there is no resolution.

So I wonder if anyone may help.

Thanks

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: How to set the path of a file as the current directory of gvim on linux automatically when it is opened ?

Gary Johnson-4
On 2010-01-23, Lenin Lee wrote:
> On Windows, when I double click a file and open it using gvim, the path of the
> file will be set as the current directory of gvim.
>
> But when I do the same thing on linux, the current directory of gvim always is
> my home directory.
>
> I searched for the question with google, but there is no resolution.
>
> So I wonder if anyone may help.

You didn't say what the problem was for which you are seeking a
resolution, but I assume that you want gvim on Linux to behave as it
does on Windows.  If that's the case, then one solution may be found
here:

    :help autochdir

That will, however, change the current working directory whenever
you open a new file, not just when gvim starts.  You may instead
want to put something like this in your ~/.vimrc:

    au VimEnter * cd %:h

See

    :help autocommand
    :help VimEnter
    :help :cd
    :help filename-modifiers

HTH,
Gary


--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: How to set the path of a file as the current directory of gvim on linux automatically when it is opened ?

Lenin Lee
Thanks Gary, au VimEnter * cd %:h is the exact resolution to my problem.

2010/1/23 Gary Johnson <[hidden email]>
On 2010-01-23, Lenin Lee wrote:
> On Windows, when I double click a file and open it using gvim, the path of the
> file will be set as the current directory of gvim.
>
> But when I do the same thing on linux, the current directory of gvim always is
> my home directory.
>
> I searched for the question with google, but there is no resolution.
>
> So I wonder if anyone may help.

You didn't say what the problem was for which you are seeking a
resolution, but I assume that you want gvim on Linux to behave as it
does on Windows.  If that's the case, then one solution may be found
here:

   :help autochdir

That will, however, change the current working directory whenever
you open a new file, not just when gvim starts.  You may instead
want to put something like this in your ~/.vimrc:

   au VimEnter * cd %:h

See

   :help autocommand
   :help VimEnter
   :help :cd
   :help filename-modifiers

HTH,
Gary


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



--
初从文,三年不第。遂习武,校场发一矢,中鼓吏,逐之出。后学医,有所成,自撰一良方,服之,卒。

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: How to set the path of a file as the current directory of gvim on linux automatically when it is opened ?

Tony Mechelynck
In reply to this post by Lenin Lee
On 23/01/10 03:22, Lenin Lee wrote:

> On Windows, when I double click a file and open it using gvim, the path
> of the file will be set as the current directory of gvim.
>
> But when I do the same thing on linux, the current directory of gvim
> always is my home directory.
>
> I searched for the question with google, but there is no resolution.
>
> So I wonder if anyone may help.
>
> Thanks
>
> --
> You received this message from the "vim_use" maillist.
> For more information, visit http://www.vim.org/maillist.php

Next time you have a question about Vim, don't use Google to (try to)
find the answer, use Vim's own help.

See
        :help
        :help :help
        :help help-context
        :help {subject}
        :help :helpgrep

Best regards,
Tony.
--
The Great Bald Swamp Hedgehog:
        The Gerat Bald Swamp Hedgehog of Billericay displays, in
courtship, his single prickle and does impressions of Holiday Inn desk
clerks.  Since this means him standing motionless for enormous periods
of time he is often eaten in full display by The Great Bald Swamp
Hedgehog Eater.
                -- Mike Harding, "The Armchair Anarchist's Almanac"

--
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

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.