I write a blog that describe the fold of vim. So I need the code like this.
+-- 15 lines: set_up_socket_dir () {--------------------------------------------
But when I yank the line, actually yank the folded code. how can i get that line from vim.
there is a vim function you may want to check out:
:h foldclosed(
you could write a :g
command line with this function:
:g/^/if line('.')==foldclosed('.') || foldclosed('.')==-1|y Z |endif
So your workflow would be:
qzq
to clear register z
...visual select lines...
'<,'>g/^/if line('.')==foldclosed('.') || foldclosed('.')==-1|y Z |endif
"zp
do paste
you could create a mapping or command if you use it often.
it works like:
To render the buffer / a range as you see it in Vim (including syntax highlighting and folding), you can use the built-in :TOhtml
command. This gets you HTML. For the entire window layout, there's the ScreenShot plugin.
If you just want the plain text, I would launch console Vim, select the entire contents with the mouse, and use your terminal's copy functionality to copy the selection to the system's clipboard. (I believe you can also do this with screen or tmux.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With