Skip to content

Instantly share code, notes, and snippets.

@mawkler
Last active October 13, 2021 18:03
Show Gist options
  • Save mawkler/9c7d872c069e2ce5b2902a9ffad44ac4 to your computer and use it in GitHub Desktop.
Save mawkler/9c7d872c069e2ce5b2902a9ffad44ac4 to your computer and use it in GitHub Desktop.
Functions for zooming in GUI versions of Vim/Neovim
" Increases the font size with `amount`
function! Zoom(amount) abort
call ZoomSet(matchstr(&guifont, '\d\+$') + a:amount)
endfunc
" Sets the font size to `font_size`
function ZoomSet(font_size) abort
let &guifont = substitute(&guifont, '\d\+$', a:font_size, '')
endfunc
noremap <silent> <C-+> :call Zoom(v:count1)<CR>
noremap <silent> <C--> :call Zoom(-v:count1)<CR>
noremap <silent> <C-0> :call ZoomSet(11)<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment