Friday, June 17, 2011

Re: menu.vim: reference to another menu line command

Yes it gives the output what I want (in the commandline) but not the
output what I want as it gave before. Can't find the reason. I send
you my function also:

function! s:CopyMatchesLines(type,kind)
let posinit = getpos(".")

if a:type == "'<,'>"
let StartPosition = line("'<")
let EndPosition = line("'>")
else
let StartPosition = 1
let EndPosition = line("$")
call cursor(1,1)
endif

let cnt = 0
let hits = []
let snum = search(@/, 'cW')
while snum > 0
let enum = search(@/, 'ceW')
if snum >= StartPosition && enum <= EndPosition
call extend(hits, getline(snum, enum))
let cnt += 1
normal! $
endif
let snum = search(@/, 'W')
endwhile

if cnt > 0
if a:kind == ""
let @+ = join(hits, "\n") . "\n"
elseif a:kind == "append"
let @+ .= join(hits, "\n") . "\n"
elseif a:kind == "register"
let @B = @+
endif
endif

call cursor(posinit[1], posinit[2])
if cnt == 0
echomsg "No hits"
else
if a:kind == ""
echomsg cnt 'lines copied to clipboard.'
elseif a:kind == "append"
echomsg cnt 'lines appended to clipboard.'
elseif a:kind == "register"
echomsg cnt 'lines appended to Register B.'
endif
endif
endfunction

Can you please give it a try?

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