How can I save a text block in visual mode to a file in Vim?

后端 未结 8 2132
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 18:54

The title is very descriptive. Just in case, I will give an example:

START BLOCK1
something
END BLOCK1

START BLOCK2
something
somenthing...
END BLOCK2
         


        
8条回答
  •  执笔经年
    2020-12-23 19:25

    Like @dronus mentioned in the comments, the :w !pbcopy suggestions does not copy correctly because it copies the entire line. If I want to copy only the url in a line, I will not be able to. Here's a line that you can add to your .vimrc file so that everytime you hit CTRL-C, the selected line in your vim will be copied to clipboard:

    map  y:e ~/clipsongzboardP:w !pbcopy:bdelete!
    

    If you'd like to read details about what this does, you can read about this on my blog

    Its the same implementation as what @rmeador suggested.

提交回复
热议问题