Loading ...
Sorry, an error occurred while loading the content.

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

Expand Messages
  • ping
    hi chris: this works! thanks! regards ping ... -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you
    Message 1 of 25 , May 31, 2012
    • 0 Attachment
      hi chris:
      this works!

      thanks!

      regards
      ping

      On May 31, 1:21 am, "Christian Brabandt" <cbli...@...> wrote:
      > On Wed, May 30, 2012 20:17, ping wrote:
      > > 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?
      >
      > I think, this should do:
      >
      > function! CopyNonFolded() range
      > let lnum= a:firstline
      > let buffer=[]
      > while lnum <= a:lastline
      >      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
      >
      > com! -range=% CopyFolds :<line1>,<line2>call CopyNonFolded()
      >
      > You can then use the command Copyfolds with or without a selected range
      > (in which case it selects the complete file).
      >
      > regards,
      > Christian

      --
      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
    Your message has been successfully submitted and would be delivered to recipients shortly.