我刚刚创建了我的第一个VIM脚本,是用Python编写的。这是一个从目录(/vim/etc/colors)切换颜色方案的简单脚本。我想知道如何在配色方案更改后用所选配色方案的名称将通知发送到vim的“statusline”。在
rson回答了我的问题,这里有一个更新(并调试过)的脚本版本,供感兴趣的人使用(就我所能测试的而言,效果很好)
执行了AI和Caleb的建议,谢谢!以下内容:
" toggleColorScheme 0.9 (l) 2009 by Jasper Poppe <jpoppe@ebay.com>
" cycle through colorschemes with F8 and Shift+F8
nnoremap <silent><F8> :call ToggleColorScheme("1")<CR>
nnoremap <silent><s-F8> :call ToggleColorScheme("-1")<CR>
" 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
既然你在这里更新脚本
而不是
也许吧
^{pr2}$vim.command('redraw | echo "%s"' % colorschemes[position])
来自
:help echo
:相关问题 更多 >
编程相关推荐