Search code examples
vimfoldyank

how to yank a code block without folded content?


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.


Solution

  • 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.)