VIM's power keeps surprising me. I just wrote a dancing doll script for vim, a screensaver of sorts. Just create a file in your ~/.vim/plugin/ and call it dance.vim, copy and paste the following in it; Or just get dance.vim from here, put it in ~/.vim/plugin/ and restart vim. Then : Dance should show you some dancing dolls.
" A VIM dancing doll! function! Dance() if &modifiable " This variable decides if the main loop is running let l:runme = 1 " Set a mark for us to get back to the line user " was working on mark L " The main loop while l:runme " Invert the case normal Hg~L redraw " If the user hit a char, then we ought to get out if l:runme && getchar(1) let l:runme = 0 endif " If we are still running: " Sleep a sec to give the feel of animation if l:runme sleep 1 endif " Undo the reverse-case normal u redraw if l:runme && getchar(1) let l:runme = 0 endif if l:runme sleep 1 endif endwhile " Get rid of the "modidfied # lines" kind of message echo '' " Move to the mark, the line user was editing normal 'L " Not modifiable, Cant run Dance.. else echo 'Can run Dance only on modifiable buffers' endif endfunction " Command to call the function command! Dance call Dance() " Key map to call the function nmap <silent> <Leader>sv :call Dance()<CR>
A couple of things to note:
- Pressing any key takes you back to editing, with a maximum of 1 second delay.
- The script sets a mark (L): this is so that it can take you back to the line you were editing once the script ends. This has a side effect that you will lose any previous mark set in L.
Happy vimming.. :-)