Tuesday, February 23, 2010

Re: full path filenames on jump to tag

Hi,
Thanks for the reply.

I know about expand, and fnamemodify, but the question is how would
one use them to modify the name of the current file (or e.g. the file
about to be opened in a pre-open autocmd)?

> Normally, the filename as displayed on the status line is relative to
> the current directory if possible
At least in my case, if you do a :new and type the full path of the
file, the full path will be shown.

I actually found a simple fix to my problem.. doing a "cd ." refreshes
the name of all buffers and the relative name is shown afterwards, so
just doing this fixes my issue:
autocmd BufRead * cd .

Thanks,
Radu


On Feb 23, 2:43 pm, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:
> On -10/01/37 20:59, Radu wrote:
>
> > I have this annoyance which I don't know how to fix. When I jump to a
> > tag, the opened filename has full path, even if I am in the exact same
> > directory. For example, I am in "/dir" editing file "/dir/x.c". I jump
> > to a tag and the file "/dir/y.c" is opened.
>
> > I would like if the filename is just "y.c" instead of "/dir/y.c" (/dir
> > is in my case a very long path). Is there any way to do this?
> > Basically I want to modify the file name to the result of
> > expand('%:.').
>
> Normally, the filename as displayed on the status line is relative to
> the current directory if possible; ":pwd" will tell you what it is
> (maybe it isn't what you think?)
>
> To set the currint directory for the current window to the directory of
> the current file, use ":lcd %:p:h". Then only the filename should appear
> on the statusline.
>
> To maximally shorten a file path (e.g. to set a variable to it etc.),
> you can use fnamemodify(filename, ':p:~:.')
>
> See
>         :help :pwd
>         :help :lcd
>         :help expand()
>         :help fnamemodify()
>         :help filename-modifiers
>
> Best regards,
> Tony.
> --
> The idea there was that consumers would bring their broken electronic
> devices, such as television sets and VCR's, to the destruction centers,
> where trained personnel would whack them (the devices) with
> sledgehammers.  With their devices thus permanently destroyed,
> consumers would then be free to go out and buy new devices, rather than
> have to fritter away years of their lives trying to have the old ones
> repaired at so-called "factory service centers," which in fact consist
> of two men named Lester poking at the insides of broken electronic
> devices with cheap cigars and going, "Lookit all them WIRES in there!"
>                 -- Dave Barry, "'Mister Mediocre' Restaurants"

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: