bairui

VimMovie - now with subtitles! :-D

Oct 12th, 2011
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 0.78 KB | None | 0 0
  1. function! StartPlayer()
  2.   let s:prevh = &previewheight
  3.   set previewheight=3
  4.   pedit subtitles.txt
  5. endfunction
  6.  
  7. function! StopPlayer()
  8.   pclose
  9.   let &previewheight=s:prevh
  10. endfunction
  11.  
  12. function! Play()
  13.   call StartPlayer()
  14.   let commands = []
  15.   redir => commandstr
  16.   function Do
  17.   redir END
  18.   let commands = split(commandstr, '\n')[1:-2]
  19.   for c in commands
  20.     let cmd = substitute(c, '^\s*\d\+\s*', '', '')
  21.     call writefile([cmd], 'subtitles.txt')
  22.     pedit! subtitles.txt
  23.     exe cmd
  24.     redraw!
  25.     sleep 1
  26.   endfor
  27.   call StopPlayer()
  28. endfunction
  29.  
  30. function! Do()
  31.   normal G
  32.   call setline('.', 'one two three four five')
  33.   call setline('.', split(getline('.'), '\s\+', '\n'))
  34.   exe "normal \<c-v>$G"
  35.   normal y
  36.   normal P
  37. endfunction
  38.  
  39. call Play()
  40.  
  41.  
  42.  
  43.  
Add Comment
Please, Sign In to add comment