Saturday, August 15, 2015

Re: prevent resizing of particular buffer

Hey again,

i solved it:

if (winheight(0)!=&lines-2)
nnoremap <a-k> <C-w>-
endif
(changed j to k, because i mistaken them before)

return the height of the current window and compare it to the height of
the whole vim window (which includes one line for the statusline and one
for the command line, so we need to subtract that.)

=> when it is equal, the current window uses the whole vim window, so
don't resize it, as that would increase the command line and is useless
=> when it is not equal, the current window shares the vim window height
with another window, so resizing the height of one window increases not
the statusline; we can allow it

Thanks & regards


Am 14.08.2015 23:30 schrieb taschentuch@posteo.de:
> Am 11.08.2015 22:03 schrieb Christian Brabandt:
>> On Di, 11 Aug 2015, taschentuch@posteo.de wrote:
>>
>>> i have that here
>>>
>>> nnoremap <s-j> <C-w>-
>>> nnoremap <s-k> <C-w>+
>>
>> Are you sure, you want to map away 'J' and 'K'? If so, you might want
>> to
>> use J and K directly. It is certainly cleaner and I am not exactly
>> certain, that <s-j> will work. In any case, you might want to read at
>> :h J and :h K to see, what you map away.
>>
>>> in my vimrc. In a single buffer, Shift-j results in resizing my
>>> airline buffer. (Im not sure about that, but i think the airline
>>> "statusline" is a seperate buffer)
>>
>> No, airline is a statusline. That is no buffer. You are simply
>> decreasing the window size and therefore increasing the command line
>> (e.g. where you enter ':' ex commands)
>>
>>> Anyways, how can i prevent that resizing?
>>
>> Use an expression mapping, e.g. something like this
>> nnoremap <expr> <c-w>j winnr('$')>1?'<c-w>-':''
>>
>> This maps Ctrl-W j to decrease the window size, only if there are
>> several windows open, else do nothing.
>>
>> See
>> :h :map-<expr>
>> :h winnr()
>> :h expr1
>>
>> Best,
>> Christian
>> --
>> Wenn die Kuh am Himmel schwirrt, dann hat sich die Natur geirrt.
>>
>> --
>
> Hey,
>
> first of all: thanks for the warning of using <s-j> and for the
> commands, i think they will be useful. I'm still struggeling with your
> command, but i'll certainly just need to read more about them. But i
> don't think it helps in that situation (at least in the actual
> state), because i can increase my command line independently of how
> many windows are open or how they are positioned.
> The only thing that prevents that behavior is when i have a vertical
> split, that uses the whole width.
>
> thanks after all
>
> regards
>
> --

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: