I have two tabs open, file1.txt and file2.txt, each with different content.
How can I copy the whole content of file1.txt and overwrite file2.txt with it, resulting in both files having the same content.
This is obviously doable with yanking manually, but I figured there's probably a nice combo that does it all in one go.
Edit : Based on Rich's answer, I ended up doing this :
" SplitOverwrite()
" Yanks all content of the current window and pastes it
" into the adjascent window, overwriting all existing content
function! SplitOverwrite()
" Yank the whole file content
%yank
" Move cursor to the window right
wincmd w
" Delete the whole file content
%delete
" Puts the text from register O after the current line
put 0
" Deletes the first (empty) line of the file
1delete
" Save the file
w
" Short version
"%y|winc w|%d|pu0|1d|w
endfunction
nnoremap <leader>so :call SplitOverwrite()<CR>