Skip to content

Instantly share code, notes, and snippets.

@qstrahl
Last active December 17, 2015 10:28
Show Gist options
  • Save qstrahl/5594655 to your computer and use it in GitHub Desktop.
Save qstrahl/5594655 to your computer and use it in GitHub Desktop.
Overload of Vim's default `<C-W>=` normal command that sets the preview window's height to `&previewheight`
function! s:CustomWincmdEquals(visual)
try
let w = winnr()
wincmd P
exe &previewheight.'wincmd _'
exe w.'wincmd w'
catch /^E441:/
continue
finally
return "\<C-W>=" . (a:visual ? 'gv' : '')
endtry
endfunction
nno <silent> <Plug>CustomwincmdEquals @=<SID>CustomWincmdEquals(0)<CR>
vno <silent> <Plug>CustomwincmdEquals @=<SID>CustomWincmdEquals(1)<CR>
nmap <C-W>= <Plug>CustomwincmdEquals
vmap <C-W>= <Plug>CustomwincmdEquals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment