From 2d9cbaf40c685aca0fa05ea15195d55bbea083f1 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Mon, 8 Jul 2013 15:01:34 +0300 Subject: [PATCH] Added functions to change font size Added functions to change font size (source: http://vim.wikia.com/wiki/Change_font_size_quickly) Wrote another function to reset font-size to predefined default size. Minor changes (rearranged bundle list, etc). --- .vimrc | 74 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 13 deletions(-) diff --git a/.vimrc b/.vimrc index 1a28310..663b3e2 100644 --- a/.vimrc +++ b/.vimrc @@ -10,8 +10,11 @@ set shortmess=atI set scrolloff=8 " Set fonts -set encoding=utf-8 +let s:maxfontsize = 25 +let s:minfontsize = 6 +let s:regularfontsize = 10 set guifont=Menlo\ for\ Powerline\ 10 +set encoding=utf-8 set linespace=2 " Set colors @@ -106,7 +109,6 @@ nnoremap s sj " Shift-Tab to go backwards in insert mode imap < :tabprevious nnoremap :tabnext @@ -115,34 +117,80 @@ inoremap :tabpreviousi inoremap :tabnexti inoremap :tabnew +" increase/decrease/reset font size +let s:pattern = '^\(.* \)\([1-9][0-9]*\)$' + +function! AdjustFontSize(amount) + if has("gui_gtk2") && has("gui_running") + if (a:amount == 0) + let fontname = substitute(&guifont, s:pattern, '\1', '') + let newfont = fontname . s:regularfontsize + let &guifont = newfont + else + let fontname = substitute(&guifont, s:pattern, '\1', '') + let cursize = substitute(&guifont, s:pattern, '\2', '') + let newsize = cursize + a:amount + if (newsize >= s:minfontsize) && (newsize <= s:maxfontsize) + let newfont = fontname . newsize + let &guifont = newfont + endif + endif + else + echoerr "You need to run the GTK2 version of Vim to use this function." + endif +endfunction + +function! LargerFont() + call AdjustFontSize(1) +endfunction +command! LargerFont call LargerFont() + +function! SmallerFont() + call AdjustFontSize(-1) +endfunction +command! SmallerFont call SmallerFont() + +function! DefaultFont() + call AdjustFontSize(0) +endfunction +command! ResetFont call DefaultFont() + +nnoremap + :LargerFont +nnoremap - :SmallerFont +nnoremap 0 :ResetFont + " Bundles set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " From vim-scripts +Bundle 'The-NERD-tree' +Bundle 'SingleCompile' Bundle 'genutils' Bundle 'Nibble' -Bundle 'SingleCompile' -Bundle 'The-NERD-tree' -Bundle 'jiangmiao/auto-pairs' -Bundle 'abijr/colorpicker' +Bundle 'gmarik/vundle' +Bundle 'Lokaltog/vim-powerline' +Bundle 'terryma/vim-multiple-cursors' Bundle 'kien/ctrlp.vim' Bundle 'godlygeek/tabular' Bundle 'majutsushi/tagbar' +Bundle 'jiangmiao/auto-pairs' +Bundle 'bronson/vim-trailing-whitespace' +Bundle 'abijr/colorpicker' Bundle 'tpope/vim-commentary' Bundle 'tpope/vim-endwise' Bundle 'tpope/vim-fugitive' -Bundle 'pangloss/vim-javascript' -Bundle 'jelera/vim-javascript-syntax' -Bundle 'terryma/vim-multiple-cursors' -Bundle 'Lokaltog/vim-powerline' Bundle 'tpope/vim-repeat' -Bundle 'vim-ruby/vim-ruby' Bundle 'tpope/vim-sensible' Bundle 'tpope/vim-surround' -Bundle 'bronson/vim-trailing-whitespace' -Bundle 'gmarik/vundle' +Bundle 'xolox/vim-notes' +Bundle 'xolox/vim-misc' + +" Language Specific +Bundle 'vim-ruby/vim-ruby' +Bundle 'pangloss/vim-javascript' +Bundle 'jelera/vim-javascript-syntax' " NERDTree map :NERDTreeToggle