Thursday, September 30, 2010

Re: Question? passing visual selection to function

On Sep 29, 10:32 pm, "Christian Brabandt" <cbli...@256bit.org> wrote:
> On Thu, September 30, 2010 1:07 am, Bee wrote:
> > Is EXAMPLE 1 the only way to pass the selection to :s?
> > Making it necessary to preceed the :call with <C-U> ?
>
> No functions can act on ranges as well. See the help at
> :h function-range-example and
> :h a:firstline

Thank you Christian, for helping me learn to find in the help.

It looks like I can pass the range, but it is much more work.
It is good to know about "range" and a:firstline ...
I have added these examples to my notes.

function! BlkNum() range
let g:l = 0 | let g:b = 0
execute a:firstline . "," . a:lastline . 's/^/\=BlkInc()/'
endfun
vmap <F5> :call BlkNum()<cr>


function! BlkNum()
let g:l = 0 | let g:b = 0
'<,'>s/^/\=BlkInc()/
endfun
vmap <F5> :<C-U>call BlkNum()<cr>

--
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

No comments: