tags:

views:

406

answers:

3

The title is very description. Just in case, I will take an example:

START BLOCK1
something
END BLOCK1

START BLOCK2
something
somenthing...
END BLOCK2
  1. I select the BLOCK1 in visual mode
  2. I yank it by pressing "y"
  3. How can I save the yanked BLOCK1 to some other file?
A: 

There's probably a simpler way to do this, but what I would do is create a new buffer (or tab) and then paste it in with p. You can create a new buffer with :new or a new tab with :tabnew. You can write the buffer/tab to a file as normal with :w filename.

rmeador
+2  A: 

With the block is selected, you can :'<,'>w other-file, which will write only the selected block to other-file. Hitting : in visual mode should place '<,'> into the command line for you already, so you really only have to type :w other-file.

ephemient
+6  A: 

Select the text you wish to save, in either line visual or block visual mode, and

:w new.txt
ldigas
+1 very cool command!
Masi