2 " Modified: 2011 Apr 29
3 " Maintainer: Ethan Schoonover
4 " License: OSI approved MIT license
6 if exists("g:loaded_togglebg")
9 let g:loaded_togglebg = 1
11 " noremap is a bit misleading here if you are unused to vim mapping.
12 " in fact, there is remapping, but only of script locally defined remaps, in
13 " this case <SID>TogBG. The <script> argument modifies the noremap scope in
14 " this regard (and the noremenu below).
15 nnoremap <unique> <script> <Plug>ToggleBackground <SID>TogBG
16 inoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>a
17 vnoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>gv
18 nnoremenu <script> Window.Toggle\ Background <SID>TogBG
19 inoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>a
20 vnoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>gv
21 tmenu Window.Toggle\ Background Toggle light and dark background modes
22 nnoremenu <script> ToolBar.togglebg <SID>TogBG
23 inoremenu <script> ToolBar.togglebg <ESC><SID>TogBG<ESC>a
24 vnoremenu <script> ToolBar.togglebg <ESC><SID>TogBG<ESC>gv
25 tmenu ToolBar.togglebg Toggle light and dark background modes
26 noremap <SID>TogBG :call <SID>TogBG()<CR>
29 let &background = ( &background == "dark"? "light" : "dark" )
30 if exists("g:colors_name")
31 exe "colorscheme " . g:colors_name
35 if !exists(":ToggleBG")
36 command ToggleBG :call s:TogBG()
39 function! ToggleBackground()
40 echo "Please update your ToggleBackground mapping. ':help togglebg' for information."
43 function! togglebg#map(mapActivation)
45 exe "silent! nmap <unique> ".a:mapActivation." <Plug>ToggleBackground"
46 exe "silent! imap <unique> ".a:mapActivation." <Plug>ToggleBackground"
47 exe "silent! vmap <unique> ".a:mapActivation." <Plug>ToggleBackground"
53 if !exists("no_plugin_maps") && !hasmapto('<Plug>ToggleBackground')
54 call togglebg#map("<F5>")