Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move section to new file in vim

Tags:

vim

I have a section in file1 which should be moved to file2. Normally I'd do this by visually-selecting the block, deleting it, :wq from file1, open file2, then paste.

Is there an easy way to move a block of text from file to file2 without closing vim?

like image 643
simont Avatar asked May 15 '12 12:05

simont


1 Answers

You could open your new file in a split using :sp newfile and then delete the block as normal from your first file. Then, change to the other split with ctrl w and w. Then use p to put the deleted content into the other file.

like image 166
Jani Hartikainen Avatar answered Oct 17 '22 19:10

Jani Hartikainen