Am 23.07.2011 00:59, schrieb Jose Caballero:
Hi,

I wanted to thank you guys for the patience, and for all the tips.
I am quite new with Vimscript, so everything is hard to me. But that is the
reason I keep trying, to learn and to educate myself. Sorry for bothering
you guys.
As I said, trying to educate myself with Vimscript, I am still trying to do
it searching for first and last line in the block, and then iterate over
them.

So far, that is the best solution I have. It is quite ugly, but seems to
work...


function Comment()
         let firstline = search('^\s*$', 'bnW') + 1
         let lastline = search('^\s*$\|\%$', 'nW', line('$'))
         if lastline != line('$')
                 let lastline = lastline - 1
         endif
         for linenum in range(firstline, lastline)
                 let oldline = getline(linenum)
                 let newline = '#'.oldline
                 call setline(linenum, newline)
         endfor
endfunction

This one uses the "ip" text object:


func! CommentPar()
    set opfunc=s:OpRange
    normal! g@ip
endfunc

func! s:OpRange(...)
    '[,']call setline(".", "# ". getline("."))
endfunc


--
Andy

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to