Wednesday, March 2, 2011

Re: Incorrect working directory in gvim launched from Konqueror

Hi Jean!

On Di, 01 Mär 2011, Jean Johner wrote:

> I can understand your preferences but consider the following facts:
>
> - launching gvim from the command line in a subdirectory always
> results in the subdirectory to be the working directory.
> I see no reason why double-clicking in Konqueror should behave
> differently. In most situations, people launching gvim in a
> subdirectory want to open other files in the same directory. By the
> way, other people in this thread seem to suffer from the present
> situation.
>
> - The behaviour would be consistent with the Windows behaviour
>
> - The behaviour would be compatible with the behaviour of almost all
> other text editors in KDE (Emacs, XEmacs, Nedit, Kwrite, Kate). An
> exception is Kedit which behaves like gvim.

The behaviour is already built into vim. But currently it only works
when dragging a file onto gvim and holding down the shift key. I don't
know, whether vim can distinguish between being called from a file
manager and from the commandline.

Hm, but wait, you should be able to script something? Using the solution
from Jürgen, that can be slightly improved to the following:

(untested)
au VimEnter * if empty($TERM) | sil cd %:h | endif

I think, it doesn't even matter, if the filename is given as relative or
absolute path, because even when given just the filename without a path
or no filename at all, ':h' will expand to '.' which is save in that
case. In any case, the check for an empty $TERM variable should prevent
changing the directory, when called from the command line.

regards,
Christian

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

No comments:

Post a Comment