Вы можете определить функцию, подобную следующей
function! BD()
let l:t = localtime()
if l:t % 3 == 0
normal aThe bus departs
elseif l:t % 3 == 1
normal aThe bus drives away
else
normal aThe bus takes off
endif
endfunction
, а затем объявить следующее imap
:
:imap bd <ESC>:call BD()<CR>a
С этого момента, ввод bd
в режиме вставкиследует вставить одну из трех случайных строк.
Редактировать : Что касается вопроса, может ли быть несколько шаблонов: если я правильно понял вопрос, это возможно с чем-то вроде:
let g:abbreviations = [
\ ['The bus departs', 'The bus drives away', 'The bus takes off'],
\ ['foo' , 'bar' , 'baz' ],
\ ['That''s ok' , 'That''s fine' , 'That''s good' ],
\ ['more' , 'less' , 'the same' ],
\ ]
function! ExpandAbbr(abbr_no)
let l:t = localtime()
return g:abbreviations[a:abbr_no][l:t % 3]
endfunction
iabbr <expr> bd ExpandAbbr(0)
iabbr <expr> pg ExpandAbbr(1)
iabbr <expr> ok ExpandAbbr(2)
iabbr <expr> mo ExpandAbbr(3)