Sunday, September 16, 2012

Re: Buffer name changed after :edit command

On 16/09/12 19:01, Timothy Madden wrote:
> On 09/16/2012 07:34 PM, Tony Mechelynck wrote:
>> On 16/09/12 15:18, Timothy Madden wrote:
>>> Hello
>>>
>>> In some situation if I try to edit a file like with
>>> :edit plugin/script.vim
>>> I may end up with a buffer name like '../.vim/plugin/script.vim'
>>>
>>> Note though two paths are equivalent, assuming the current directory is
>>> named ".vim", still the buffer names are not the same in a literal
>>> sense.
>>>
>>> This will happen when I already have the file opened (or listed) with
>>> the long name (../.vim/plugin/script.vim), then I try to :edit it in a
>>> different window with the short name.
>>>
>>> In my script I would like to use :MkVimball command plugin from the
>>> standard vimball plugin, and if I ran into this problem than MkVimball
>>> will create for example a file like ../../src/vim/plugin/scriptname.vim
>>> in the vimball archive. Even if the filename I pass to MkVimball really
>>> is the right one, plugin/scriptname.vim.
>>>
>>> For this to trigger, the MkVimball command should be seen from within a
>>> :source'd script, and not directly from the command line. Anyway, I
>>> think this should not happen (actually, I find this a bug in the
>>> standard vimballPlugin, but that is another problem).
>>>
>>> Is there a way to know if a file is already loaded/listed in a buffer,
>>> with a modified path name like ../dir/script.vim instead of script.vim ?
>>>
>>> Are there other cases where such a different path name may exist ?
>>>
>>> Thank you,
>>> Timothy Madden
>>>
>>
>> Vim identifies files by their full path, but displays them (e.g. on the
>> statusline) by a shorter path if possible. If you have several windows
>> on a single buffer, but with different "local current directories", it
>> may happen that Vim can shorten the name in one window but not in the
>> other. However it should display all statuslines relative to what is the
>> current directory now: if you change windows, and the LCDs are
>> different, statuslines may change.
>
> I have the same file, the same directory, two windows with no local
> directory, and the same file name in both (in other words, one buffer
> with two windows).
>
> The problem is the file name is ../.vim/plugin/script.vim, and I want to
> open plugin/script.vim
>
> Thank you,
> Timothy Madden
>

When I have a file opened in a window with the long name, and then I use
:sv or :new with the short name as argument, then both statuslines
display the short name from then on, howsoever I switch windows among
them. Example:

:pwd
/root/.mozilla/seamonkey/nexrdon9.default
:sv ../nexrdon9.default/chrome/userChrome.css
statusline says: ../nexrdon9.default/chrome/userChrome.css
:sv chrome/userChrome.css
_both_ statuslines say: chrome/userChrome.css
Ctrl-W p
both statuslines still say: chrome/userChrome.css

Similarly with
../../seamonkey/nexrdon9.default/chrome/userContent-example.css : as
soon as I supply the short name, _both_ windows for that file get (and
keep) the short name in their statusline.


What happens if you open the file in a window with the short name first,
and then pass expand('%') to MkVimball?


FWIW, I'm using gvim 7.3.661 (Huge) with GTK2-GNOME GUI.


Best regards,
Tony.
--
In Blythe, California, a city ordinance declares that a person must own
at least two cows before he can wear cowboy boots in public.

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