3

How do I get the width in columns of the area available for text in the current split. If columns is 110, but 5 of that is gutter, signs and numbers, I want 105.

EDIT: This is a duplicate of https://stackoverflow.com/questions/26315925/get-usable-window-width-in-vim-script/26318602#26318602

(but I can't flag it as a duplicate because it's not in Vi and Vim)

3

I hate to see a question count against the site's unanswered list when there are good answers linked, so here's a community wiki containing some of those answers.

From https://stackoverflow.com/questions/26315925/get-usable-window-width-in-vim-script we have Christian Brabandt's answer, a snippet that uses redirection to make a query and math to calculate the result:

redir =>l:a |exe "sil sign place buffer=".bufnr('')|redir end
let l:signlist=split(l:a, '\n')
let width=winwidth(0) - &numberwidth - &foldcolumn - (len(signlist) > 2 ? 2 : 0)

On that same question, Ingo Karkat mentioned that he has a vimscript with that and other functions:

http://www.vim.org/scripts/script.php?script_id=4433

Use the ingo#window#dimensions#NetWindowWidth() function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.