Run vimscript, run!

2009-03-20 14:01; Tags: ,
:h :@

This is the command every Vim plugin developer should be aware of. I wish I knew about it earlier.

" eval selected vimscript
vmap <Leader>r "vy:@v<CR>
" eval vimscript line
nmap <Leader>r "vyy:@v<CR>

Now with this screwdriver in my hands I can tinker at variables and functions of my plugin/script/colorscheme easily. That’s convenient. :)

The only drawback is that it can’t eval vimscript’s longlines. Those with `\` in the beginning:

" remove trailing spaces
map <F4> m`:silent! %s/\(\s\+$\)\\|\(\r$\)//g<CR>``
      \:echo "Remove trailing spaces and ^Ms ..."<CR>

Leave a Reply

Powered by WordPress