使用vim将代码块从正在编辑的文件移至另一个文件。
有什么花招可以提高生产力吗?
这个问题与下面的网址很接近,但不完全相同
# tasks
identity lines range in file_A where you are working
append the code block to file_B
remove the code block from file_A
我以前的常规-4个步骤
# write down line range, exit vim
sed -n 1,33p file.pl >> lib/module.pm
vim lib/module.pm - to check
vim file.pl again to delete the code block
如果不必打开目标文件,则可以这样操作:
执行以下命令:
:w >>file_B
激活选择后,它将实际显示并执行:
:'<,'>w >>file_B
然后只需键入gvd(或d'])即可删除先前选择的文本。
为了避免在文件不存在时出现错误!,请在写入命令中添加一个bang :
:'<,'>w! >>file_B