From 69a6175be2afd9f391c965c40ea8ccf5261ccae9 Mon Sep 17 00:00:00 2001 From: Roman Dobosz Date: Tue, 29 Oct 2013 20:56:17 +0100 Subject: [PATCH] Added Linux fonts support --- README | 30 ++++++++++++++------- plugin/zoom.vim | 70 ++++++++++++++++++++++++++++++++++--------------- 2 files changed, 69 insertions(+), 31 deletions(-) diff --git a/README b/README index 2fd9591..75044b3 100644 --- a/README +++ b/README @@ -1,19 +1,29 @@ -This is a mirror of http://www.vim.org/scripts/script.php?script_id=2321 - -Control Vim editor font size with key "+", or key "-". -Press "+" key, Vim editor gui font size will change bigger. -And, press "-" key, Vim editor gui font size will change smaller. +This is fork of a mirror of http://www.vim.org/scripts/script.php?script_id=2321 +Control Vim editor font size with keyboard or mouse. This plugin is for GUI only. Normal Mode: - + ... change font size bigger - - ... change font size smaller + Keypad + ... incerase font size + Ctrl-MouseWheelUp + + Keypad - ... decrease font size + Ctrl-MouseWheelDown + + Keypad / ... reset font size to initial state Command-line Mode: - :ZoomIn ... change font size bigger - :ZoomOut ... change font size smaller - :ZoomReset ... reset font size changes. + :ZoomIn ... incerase font size + :ZoomOut ... decrease font size + :ZoomReset ... reset font size to initial state +============================================================================== +1. Copy the zoom.vim script to + $HOME/vimfiles/plugin or $HOME/.vim/plugin directory. + Refer to ':help add-plugin', ':help add-global-plugin' and + ':help runtimepath' for more details about Vim plugins. + Or just use pathogen (https://github.com/tpope/vim-pathogen) + +2. Restart Vim. diff --git a/plugin/zoom.vim b/plugin/zoom.vim index fcd8fa6..e17dafe 100644 --- a/plugin/zoom.vim +++ b/plugin/zoom.vim @@ -1,3 +1,9 @@ +"The guard. Zoom will only work in graphical Vim. For terminal version try to +"find out how to increase/decrease font size in your terminal emulator. +if !has("gui") + finish +endif + if &cp || exists("g:loaded_zoom") finish endif @@ -14,24 +20,43 @@ command! -narg=0 ZoomIn :call s:ZoomIn() command! -narg=0 ZoomOut :call s:ZoomOut() command! -narg=0 ZoomReset :call s:ZoomReset() -" map -nmap + :ZoomIn -nmap - :ZoomOut +" map. I like keypad mappings +nmap :ZoomIn +nmap :ZoomOut +nmap :ZoomReset + +nmap :ZoomIn +nmap :ZoomOut " guifont size + 1 function! s:ZoomIn() - let l:fsize = substitute(&guifont, '^.*:h\([^:]*\).*$', '\1', '') - let l:fsize += 1 - let l:guifont = substitute(&guifont, ':h\([^:]*\)', ':h' . l:fsize, '') - let &guifont = l:guifont + " Let's check, what system we are dealing with + if has("win32") + let l:fsize = substitute(&guifont, '^.*:h\([^:]*\).*$', '\1', '') + let l:fsize += 1 + let l:guifont = substitute(&guifont, ':h\([^:]*\)', ':h' . l:fsize, '') + let &guifont = l:guifont + elseif has('unix') + " TODO: Might not work on OS X + let l:font = split(&guifont) + let l:font[-1] = l:font[-1] + 1 + let &guifont = join(l:font, " ") + endif endfunction " guifont size - 1 function! s:ZoomOut() - let l:fsize = substitute(&guifont, '^.*:h\([^:]*\).*$', '\1', '') - let l:fsize -= 1 - let l:guifont = substitute(&guifont, ':h\([^:]*\)', ':h' . l:fsize, '') - let &guifont = l:guifont + " Same as above + if has("win32") + let l:fsize = substitute(&guifont, '^.*:h\([^:]*\).*$', '\1', '') + let l:fsize -= 1 + let l:guifont = substitute(&guifont, ':h\([^:]*\)', ':h' . l:fsize, '') + let &guifont = l:guifont + elseif has('unix') + let l:font = split(&guifont) + let l:font[-1] = l:font[-1] - 1 + let &guifont = join(l:font, " ") + endif endfunction " reset guifont size @@ -43,7 +68,7 @@ let &cpo = s:save_cpo finish ============================================================================== -zoom.vim : control gui font size with "+" or "-" keys. +zoom.vim : control gui font size with "+" or "-" keypad keys. ------------------------------------------------------------------------------ $VIMRUNTIMEPATH/plugin/zoom.vim ============================================================================== @@ -53,21 +78,23 @@ email : mail@nanasi.jp version : 2008/07/18 10:00:00 ============================================================================== -Control Vim editor font size with key "+", or key "-". -Press "+" key, Vim editor gui font size will change bigger. -And, press "-" key, Vim editor gui font size will change smaller. - +Control Vim editor font size with keyboard or mouse. This plugin is for GUI only. Normal Mode: - + ... change font size bigger - - ... change font size smaller + Keypad + ... incerase font size + Ctrl-MouseWheelUp + + Keypad - ... decrease font size + Ctrl-MouseWheelDown + + Keypad / ... reset font size to initial state Command-line Mode: - :ZoomIn ... change font size bigger - :ZoomOut ... change font size smaller - :ZoomReset ... reset font size changes. + :ZoomIn ... incerase font size + :ZoomOut ... decrease font size + :ZoomReset ... reset font size to initial state ============================================================================== @@ -75,6 +102,7 @@ Command-line Mode: $HOME/vimfiles/plugin or $HOME/.vim/plugin directory. Refer to ':help add-plugin', ':help add-global-plugin' and ':help runtimepath' for more details about Vim plugins. + Or just use pathogen (https://github.com/tpope/vim-pathogen) 2. Restart Vim.