Tuesday, March 1, 2011

Re: Incorrect working directory in gvim launched from Konqueror

Hi Jurgen,

Thank you for your explanations.

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.

Perhaps we could vote.

Best regards

Jean Johner

On Mar 1, 3:09 pm, Jürgen Krämer <jottka...@googlemail.com> wrote:
> Hi,
>
> Jean Johner wrote:
>
> > Thank you for your answers.
> > In summary:
> > - Using "autochdir" is better than nothing, with the complications
> > described by Marco
>
> > - Using
> > au VimEnter * if expand('%') != ""' | cd %:h | endif
> > (note that the double quote must be doubled)
>
> actually, there were no double quotes in the original command, just
> two strings with single quotes: '%' and the empty string.
>
> > solves the problem (don't ask me why). Thank you J�rgen.
>
> The VimEnter event is triggered after all configurations file have been
> read and the first file, if any, has been loaded. If there is at least
> one file the % register contains its name. %:h gives the path to this
> file. %:p:h might actually be a better solution, because this takes care
> of file names without a path. On non-Unix-system this is no problem
> because :cd only prints the current directory if called without a path,
> but on Unix-systems :cd without a path changes the current directory to
> the user's home directory.
>
> > - I see no fatality why gvim is unable to have this behaviour by
> > default. Launching Nedit or emacs in the same conditions results in
> > the correct working directory. I will submit the problem to vim_dev
> > (did you eNG1Ne ?)
>
> I like the current behaviour. It's easier to change to the directory of
> a loaded file once you are inside Vim than to go back to the directory
> Vim was started from once the current directory has changed. I have
> defined two commands for this task:
>
>   :command -bar -nargs=0 CD    cd  %:p:h
>   :command -bar -nargs=0 LCD   lcd %:p:h
>
> Also the current directory is much more predictable for this use-case
>
>   vim **/files-in-subdirectories.txt
>
> ;-) It's still the directory from where you have issued the command and
> not some semi-random subdirectory.
>
> Regards,
> J�rgen
>
> --
> Sometimes I think the surest sign that intelligent life exists elsewhere
> in the universe is that none of it has tried to contact us.     (Calvin)

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