Bug#644635: vim-gui-common: Set working directory when invoking via the .desktop file

James Vega jamessan at debian.org
Sat Oct 15 03:47:28 UTC 2011


On Fri, Oct 07, 2011 at 06:31:11PM +0200, Daniel Skorka wrote:
> Hello there,
> 
> the current /usr/share/applications/gvim.desktop uses
> Exec=gvim -f %F
> which leaves the working directory set to $HOME.

Actually, it leaves it to whatever the working directory is of the
process that launches gvim.

> Therefore, commands
> like :make will fail if the file being edited is not in $HOME.
> This is often confusing, as one tends to forget this behaviour.

It's just as confusing as Vim inheriting the working directory from your
shell.  That's how spawning a child process works.  Unless it takes
measures to do otherwise, the child process has the same working
directory as the parent process.

> In
> addition, I don't think one would normally want to leave the working dir
> set to $HOME.

That's completely subjective.  I actually do leave Vim in whatever
working directory it had for a lot of my work.  I only explicitly change
the directory if I have a reason to.

> I'd like the Exec line to specifically change the working directory, for
> example by doing something like
> Exec=gvim -f -c"cd $(dirname %F)" %F
> What's your opinion?

If you want Vim's working directory to be that of the file you're
editing (which is just as likely to be wrong as $HOME is in your
example), then there's an option for that—'autochdir' (c.f. ":help
'autochdir'").

Thanks for the suggestion, but I'll be leaving it as is.

Cheers,
-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan at debian.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-vim-maintainers/attachments/20111014/73d9cb74/attachment.pgp>


More information about the pkg-vim-maintainers mailing list