diff options
author | Ethan Schoonover <es@ethanschoonover.com> | 2011-04-07 14:47:34 -0700 |
---|---|---|
committer | Ethan Schoonover <es@ethanschoonover.com> | 2011-04-07 14:47:34 -0700 |
commit | 4a0e3448833ec4092bbcce81ed2ddddd0c241aa3 (patch) | |
tree | ad7c9f1db9f8f2946c454bc05386520a5023571e /plugin | |
parent | a211ae8fc9d36d06c7718f41b7ec01fc2deb1de1 (diff) | |
download | vim-colors-solarized-4a0e3448833ec4092bbcce81ed2ddddd0c241aa3.tar.gz |
[vim] major refactoring of solarized.vim
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/togglebackground.vim | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/plugin/togglebackground.vim b/plugin/togglebackground.vim new file mode 100644 index 0000000..7663af7 --- /dev/null +++ b/plugin/togglebackground.vim @@ -0,0 +1,45 @@ +" Toggle background +" Last Change: April 7, 2011 +" Maintainer: Ethan Schoonover +" License: OSI approved MIT license + +if exists("g:loaded_ToggleBackground") + finish +endif +let g:loaded_ToggleBackground = 1 + +if !exists("no_plugin_maps") && !hasmapto('<Plug>ToggleBackground') + " map alone won't work here as it doesn't + try + silent! nmap <unique> <F5> <Plug>ToggleBackground + silent! imap <unique> <F5> <Plug>ToggleBackground + silent! vmap <unique> <F5> <Plug>ToggleBackground + finally + let g:test_val = "checked" + endtry +endif + +" noremap is a bit misleading here if you are unused to vim mapping. +" in fact, there is remapping, but only of script locally defined remaps, in +" this case <SID>TogBG. The <script> argument modifies the noremap scope in +" this regard (and the noremenu below). +nnoremap <unique> <script> <Plug>ToggleBackground <SID>TogBG +inoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>a +vnoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>gv +nnoremenu <script> Window.Toggle\ Background <SID>TogBG +inoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>a +vnoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>gv +noremap <SID>TogBG :call <SID>TogBG()<CR> + +function! s:TogBG() + let &background = ( &background == "dark"? "light" : "dark" ) | exe "colorscheme " . g:colors_name +endfunction + +if !exists(":ToggleBG") + command ToggleBG :call s:TogBG() +endif + +function! ToggleBackground() + echo "Please update your ToggleBackground mapping. ':help togglebg' for information." +endfunction + |