Wednesday, August 10, 2011

substitute function

i'm trying to substitute some patterns with a list's content.
i created a global variable imglist  first.

function Cclinks()
    let i=0
    g/src=""/s//\='src="'.g:imglist[i].'"'/g
    let i+=1
endfunction
nmap <silent> ;s :call Cclinks()<CR>

but after my calling the function Cclinks(), i found the results to be wrong. the patterns matched are all replaced with the imglist[0], not one by one,but if i just input the command let i=0 | g/src=""/s//\='src="'.g:imglist[i].'"'/g | let i=i+1 into the ex command line, it just worked as i expected.

anyone can give me any ideas?
thanks.

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