You probably should map
- append current line to some file
- do normal
nnoremap dd :.write! >> ~/different_file<CR>dd
write command can append a
range to a specified file if
>> is supplied.
. is the range of "current line".
To make it only available for a specified buffer you should create a mapping with
<buffer> argument (
nnoremap <buffer> dd :.write! >> ~/different_file<CR>dd
To properly apply this mapping to a specific buffer you will have to use autocommand:
augroup TODO | au!
au BufRead,BufNew todo.txt nnoremap <buffer> dd :.write! >> ~/different_file<CR>dd
Here you create an autogroup, clear it (needed in case you re-source your vimrc) and add autocommand for 2 events:
BufNew for a buffer named
Now if you open or create a buffer named
todo.txt buffer local mapping would be added only available in this buffer.