A fast way, working on entire lines, is to visually select the lines to move (V
...), then:
:'<,'>write! >> the_other_file.txt
... where '<,'>
is automatically appended by Vim after you press :
. This will append the range to that file, creating it if it doesn't exist. Then, a gv
in normal mode will reselect the range, so you can easily delete it (d
).
Then, it's even easier - select another range (V
...), hit :
to open command-line, Ctrl-P
to bring back the last command, Enter
to copy the lines 1. Then gvd
to delete them locally; rinse and repeat.
Alternatively, you could "cut" to a named register by appending to it (using the capital letter), e.g. on first text selection to cut: "ad
, then (repeatedly): "Ad
(on other selected text). At the end, edit the new file and paste from that register ("ap
).
1Even better, use @:
to repeat the last command (as Karl Yngve Lervåg suggests in the 1st comment below).