On 09-Mar-2011 13:25, tyru wrote:
> On Wed, Mar 9, 2011 at 7:56 PM, Ingo Karkat <[email protected]> wrote:
>> On 09-Mar-2011 10:37, tyru wrote:
>>> 1. vim -u NONE -i NONE
>>> 2. :echo strdisplaywidth("\<Tab>foo", 8)
>>>
>>> It returns 11 but I expect that the return value is 3 ("foo").
>>> I'm getting something wrong?
>>> Default 'tabstop' value is 8, so strdisplaywidth("\<Tab>") returns 8.
>>> it is expected value, though.
>>
>> 11 = 8 (<Tab>) + 3 ("foo") is correct; the <Tab> occupies 8 display cells,
>> and
>> is therefore included. The function is mostly used for visual alignment along
>> screen colums.
> I specified 8 to strdisplaywidth(), it should skip 8 display cells
> (<Tab>), doesn't it?
Ah, now I see your misunderstanding. At position 8 (which, assuming default
ts=8, yields the same result as position 0), the leading <Tab> character is
rendered in the full 8 display cells. The {col} argument doesn't cut into the
{expr} (reducing its effective width), rather it's an offset to where the full
{expr} will be rendered.
The use case behind it is this: I have a string "\<Tab>foo", and I want to print
it starting from screen column N. Tell me how many display cells the string will
take, so that I can vertically align another output below it.
-- regards, ingo
--
You received this message from the "vim_dev" 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