On 14/02/09 01:04, Nate-37 wrote:
>
>>> In Gvim, if I'm editing
>>> /home/myself/source/some/long/directory/path/MyFile.txt,
>>>
>>> the titlebar shows:
>>>
>>> MyFile.txt (/home/myself/../directory/path) in the titlebar, and I want
>>> to
>>> keep that in the titlebar.
>
>> :h pathshorten()
>
> Andy, thanks for the suggestion, but pathshorten() gives back
> /h/m/s/s/l/d/p/MyFile.txt
>
> This is /kinda/what I want, but not what Gvim has in the titlebar.
>
> Does anyone have any other suggestions for how Gvim shortens the file path
> like this:
> /home/myself/../directory/path
>
> Thanks,
> --Nate
You set the title (when it is possible to set it, i.e., in Vim versions
with +title compiled-in running either in GUI mode or in a console
terminal with a title which can be set) by using ":set title
titlestring=<value> titlelen=<number>" where the "value" is a string
which can include "tokens" starting with % as in the 'statusline'
option, and the <number> is the maximum length to use, expressed as a
percentage of the 'columns' setting -- see
:help 'titlestring'
:help 'statusline'
:help 'titlelen'
I think that this will allow you to specify how to shorten the title;
but if you don't find a setting which shortens it the way you like, you
can always program a custom function to do it yourself:
- start with expand('%:p') which returns the full path & filename of the
current file
- check its length -- either its length in bytes with strlen() or its
length in characters with strlen(substitute(..., '.', 'x', 'g') as shown
lower down in ":help strlen()". Which size function to use may depend on
the value of 'encoding' -- for instance in some CJK encodings, halfwidth
characters use one byte each and fullwidth characters use two bytes each
which makes strlen() a better candidate in those cases; OTOH in UTF-8
Latin accented characters already use two bytes each and non-Latin
characters may use (under the current Unicode standard) up to four bytes
each, so you may have to use the "character" length. Of course, in 8-bit
encodings each character is one byte.
- if too long, replace the appropriate part with a few dots and check
the length again.
Best regards,
Tony.
--
It is illegal for anyone to try and stop a child from playfully jumping over
puddles of water.
[real standing law in California, United States of America]
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---