Tony Mechelynck wrote:
> On 06/10/09 13:43, Stahlman Family wrote:
>>
>>
>> Paul wrote:
>>> On Mon, 5 Oct 2009, Brett Stahlman wrote:
>>>
>>>> nnoremap<F8> :exe "resize " . (line('.') - line('w0') + 1)<CR>\|zb
>>> Yes, you have the idea. That works for horizontal split. Now, how about for
>>> vertical split? I don't see a column() function...
>> Well, I see that Christian has already supplied you with what appears to
>> be a more complete solution, so this may not be necessary, but here's a
>> more simplistic mapping, which reflects my best guess as to what you
>> were trying to do. It works for both 'wrap' and 'nowrap'. What it does
>> is shrink the current window so that anything to the right of the cursor
>> is no longer visible. It does so without altering what is in the first
>> visible column.
>>
>> <<<All on one line...>>>
>>
>> nnoremap<silent> <F9> :if !&wrap\|let rvc = virtcol('.')\|let rc =
>> col('.')\|exe "norm! g0"\|let lvc = virtcol('.')\|exe "vert resize " .
>> (rvc - lvc + 1)\|call cursor(0, rc)\|exe "norm! ze"\|else \|exe "vert
>> resize " . col('.')\|endif<CR>
>>
>> Brett Stahlman
>
> I haven't analyzed the proposed mapping in detail, but note that the
> col() function counts memory _bytes_, i.e. always one for a hard tab
> (which occupies between one and eight screen columns, or more with
> nonstandard values of 'tabstop'), but OTOH in UTF-8 three for CJK
> characters in the BMP (below U+FFFF) and four for CJK characters above
> U+FFFF, though (as CJK "wide" glyphs) they each occupy only two screen
> cells. To count screen columns you need the virtcol() function, which
> you used elsewhere in the same mapping.
In the `if' clause, col() was used only to save starting position; since
cursor() (used to restore starting position later) uses byte offsets,
this made sense. However, virtcol() should have been used in the `else'
clause. Good catch.
Thanks,
Brett S.
>
> Best regards,
> Tony.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---