我刚刚创建了我的第一个vim脚本,它是用python编写的。这是一个从目录(/vim/etc/color s)切换配色方案的简单脚本。我想知道如何在用所选配色方案的名称更改配色方案后将通知发送到vim“statusline”。
森回答了我的问题,这里有一个更新(和调试)版本的脚本谁感兴趣(工作良好,只要我可以测试)
实施了人工智能和CALEB的建议,谢谢!以下内容:
" toggleColorScheme 0.9 (l) 2009 by Jasper Poppe
" cycle through colorschemes with F8 and Shift+F8
nnoremap :call ToggleColorScheme("1")
nnoremap :call ToggleColorScheme("-1")
" set directory with color schemes to cycle through
let g:Toggle_Color_Scheme_Path = "/etc/vim/colors"
function! ToggleColorScheme(paramater)
python << endpython
import vim
import os
paramater = (vim.eval('a:paramater'))
scheme_path = vim.eval('g:Toggle_Color_Scheme_Path')
colorschemes = [color.split('.')[0] for color in os.listdir(scheme_path) if color.endswith('.vim')]
colorschemes.sort()
if not vars().has_key('position'):
start_scheme = vim.eval('g:colors_name') + '.vim'
if start_scheme in colorschemes:
position = colorschemes.index(start_scheme)
else:
position = 0
position += int(paramater)
position %= len(colorschemes)
vim.command('colorscheme %s' % colorschemes[position])
vim.command('redraw | echo "%s"' % colorschemes[position])
vim.command('return 1')
endpython
endfunction