Resize all open windows to a specific width

1 Point

Nic West Nic West

9 years ago

Resizes all open windows to a specific width, the last window (furthest right) will be left with all left over screen width

function! WinOneWidth(width) abort
  exe "normal 99\<c-w>l"
  let l:last_window = winnr()
  exe "normal 99\<c-w>h"
  while winnr() != l:last_window
    exe "vert res" a:width
    exe "normal \<c-w>l"
  endwhile
endfunction

"Example:
nnoremap <leader>+ :call WinOneWidth(80)<CR>
nnoremap <leader>= :call WinOneWidth(90)<CR>