The title is very descriptive. Just in case, I will give an example:
START BLOCK1
something
END BLOCK1
START BLOCK2
something
somenthing...
END BLOCK2
In addition to selected answer above,
when using the mouse to select (1),
and the problem of only copying whole lines mentioned by the comment of @dronus to it, when just wanted to partly copy lines (2):
(1) At my Debian based DietPi (Raspberry PI)system, vim acts a little different like in the preferred solution above when using the mouse to enter and select 'VISUAL MODE' on my Ubuntu 16.04 work station. Then
but if I type ':' for command, it will not show up with the
'<,'>
where I can just simply add my
w new.txt
after it. So I just typed it by myself and it did work:
'<,'>w new.txt
and it copies the whole line(s) yanked content to my file 'new.txt', whereas '<,' seem to mean 'copy selected lines and '>' redirect it to the write command's referenced file.
(2) And to the problem of not pasting part of the line(s), like in @dronus comment mentioned, this solution (the selected one, first alternative) worked for me:
Edit the first file, yanking the text you want. Then open your second file from within vi (:e /path/to/other/file) and paste it (by typing p). Save it (like above ':w new.txt'.
It will then just copy the part of the lines marked up by mouse or 'y' with the cursors.
[EDIT] On my Ubuntu system: Sometimes selecting by mouse does NOT enter 'VISUAL MODE' in vim. Then the normal copy/paste can be selected using the context menu... I have not found the reason why Ubuntu changed it behaviour from a 'client acting behaviour' to a 'host' one (withUbuntu hosting the ssh bash window to my 'Client')...
Basing on @chenkaie's variant, works well for me:
let mapleader = ","
let g:mapleader = ","
vmap <leader>y y:new ~/.vbuf<CR>VGp:x<CR>
nmap <leader>p :r ~/.vbuf<CR>