On Sun, May 20, 2012 at 05:28:10AM EDT, ping wrote:
> I'm using fold a lot and wondering if there is a way to yank ONLY the
> displayed texts?
> that is , say I have following folding:
>
> 30 hostname "WASHDC core"
> 31 +-- 34 lines: aaa new-model
> 65 +-- 2 lines: !
> 67 service password-encryption
> 68 baseline show-delta-counts
> 69 !
> 70 +-- 3 lines: controller sonet 12/0
> 73 !
> 74 +-- 3 lines: controller sonet 13/0
> 77 !
> 78 +-- 23 lines: controller sonet 4/0
> 101 +-- 31 lines: !
>
> normally when you yank a folded line, it actually yank the whole
> texts that line folded, not only the displayed title.
> but I want to also have the option to do the other way -- just yank
> the texts that is getting displayed.
>
> this is kind of another good usage of folding -- generate an overview
> that can be passed to other places.
I guess you write a function that uses the following Vim functions to
extract your text and append it to a register:
:h getline()
:h line()
:h foldclose()
:h foldtextexpr()
:h setreg()
And then have mapping such as:
:nmap ,y :g/\n/call MyYank()<CR>
.. to scan the entire buffer so that when you return from MyYank() your
outline would be available in one of the A-Z registers.
I believe you'd need to keep track of whether the current line is the
top line of the fold, or you'd end up with the entire fold appended to
the register.. not what you want obviously.
There are probably less kludgy ways to do that, but that's what comes to
mind..
CJ
--
Alex Perez is aliveeeeeeee!!!
--
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
Sunday, May 20, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment