From b20c29c906e03bbe483c86013eb3ee5fec4881a4 Mon Sep 17 00:00:00 2001 From: rrueger Date: Thu, 23 Jul 2020 11:25:03 +0200 Subject: Correctly identify size of the current split Until now, I was using &columns to determine the width of available space for the statusline. However, when using a vertical split, &columns would still report the full vim window width, not the split width. The `winwidth(0)` (0 = current window) function returns the correct value. --- plugin/statusryne.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/statusryne.vim b/plugin/statusryne.vim index 48f63d4..6e84966 100644 --- a/plugin/statusryne.vim +++ b/plugin/statusryne.vim @@ -221,12 +221,12 @@ function! FileName() " 2) Show only first character of every directory in path. " 3) Show only basename. - if (&columns > len(fullname) + remainder) + if (winwidth(0) > len(fullname) + remainder) let shortpath = substitute(fullname, $HOME, '~', "") return ' ' . shortpath - elseif (&columns > len(pathshorten(fullname)) + remainder) + elseif (winwidth(0) > len(pathshorten(fullname)) + remainder) let home = pathshorten($HOME . '/') let shortpath = substitute(pathshorten(fullname), home, '~/', "") @@ -358,7 +358,7 @@ function! TabLine() " For equal with tabs, fitted to longest tab label. let g:maxlabellen = max([g:mintablabellen, MaxLen(g:tablabels)]) " For full screen width equal width tabs. - " let g:maxlabellen = &columns / tabpagenr('$') + " let g:maxlabellen = winwidth(0) / tabpagenr('$') " }}} -- cgit v1.2.3-70-g09d2