Pick your Look: Standard - Rising Blue - Retro Curves
RajeshGoli.com
- Thoughts on Technology and life...
Reason :: A VIM dancing doll
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:
Happy vimming..
Created on 10th August 2005 and modified last on 11th August 2005
Add Article Comment
Articles
Portfolio
Styles
Support this site!