Wednesday, March 24, 2010

Re: Always name buffer with respect to cwd, bug?

On 24/03/10 18:32, Aarto Matti wrote:
> Hello,
>
> :cd /usr/include/
> :e xorg/shadow.h
> :e /usr/include/xorg/site.h
>
> it names buffers as "xorg/shadow.h" and "/usr/include/xorg/site.h".
>
> :cd .
>
> now buffers are "xorg/shadow.h" and "xorg/site.h".
>
> :e /usr/include/xorg/site.h
>
> nothing changed.
>
> Is this a bug?
>
> If it names buffers according to given file path, why it didn't do this
> with :e the second time, after the buffer name changed due to cd?
> Actually why does it rename them when cwd not changed? Or why it didn't
> consider cwd the first time?
>
> Gosh, can I force it always name buffers with respect to cwd? Although I
> would like a native vim solution, I suppose I could do it with some
> autocmd, but what if a script relies on the same autocmd?
>
> Thanks.
>
> --
> Aarto

You can force Vim to display the full path on the statusline, by using a
custom status line with %F (full path to the file in the buffer) in it,
rather than %f (file path, as typed or relative to current directory).

I'm not sure how to "uniformize" the paths displayed by the :ls[!]
command. IIUC, on systems where links are possible, Vim follows them,
and makes sure that anything that refers to the same file is seen as
"the same buffer", but which name it gets may depend on how you name it
first.

In a script, to get the full path (which will stay the same no matter
from where you look at the file), you can use expand() and/or
fnamemodify() with a :p modifier, see
:help expand()
:help fnamemodify()
:help filename-modifiers
Or you can use various other modifiers: for instance, for maximum
shortness, use :~:. which will display the path relative to the current
directory if possible, otherwise relative to your home directory if
possible, otherwise as an absolute path.


Best regards,
Tony.
--
DINGO: And after the spanking ... the oral sex.
GALAHAD: Oh, dear! Well, I...
GIRLS: The oral sex ... The oral sex.
GALAHAD: Well, I suppose I could stay a BIT longer.
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD

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

No comments: