Wednesday, May 30, 2012

Re: vim: how to yank only displayed texts in folding

hi Christan:
yes that works!
thanks!

previously I got it wrong that I visually selected my text and apply
the function with that range.

b.t.w can we actually achieve that goal based on your function here?

"yank only non-folded texts
function CopyNonFolded()
let lnum=1
let buffer=[]
while lnum <= line("$")
    if (foldclosed(lnum) == -1)
        let buffer += getline(lnum, lnum)
        let lnum += 1
    else
        let buffer += [ foldtextresult(lnum) ]
        let lnum = foldclosedend(lnum) + 1
    endif
endwhile
top new
set bt=nofile
call append(".",buffer)
0d_
endfu
"

thanks again for your help!

regards
ping


On 05/22/2012 01:54 PM, Christian Brabandt wrote:
Hi ping!    On Di, 22 Mai 2012, ping wrote:    
can you let me know how to use this function in practice?  I tried visual mark then :call func..  it doesn't work.  
  Please be exact. What did you do? What happened instead? Did you get an   error message?    
  http://groups.google.com/group/vim_use/msg/dd1baac3622107c0    
Take the function CopyNonFoldedI() from here:  http://groups.google.com/group/vim_use/msg/571f070987ee35ce  and copy it into a file which you save below ~/.vim/plugin/CopyFolds.vim    Restart Vim and now you can simply call :call CopyNonFolded() and it   will create a new split buffer which contains only the fold data.    regards,  Christian  

No comments:

Post a Comment