Setting: Vim session with multiple tabs, windows, and buffers.
Goal: Make Ex command that sends selected text from active buffer to another buffer in the session (preferably with autocompletion). By this I mean the text is appended to the end of the target buffer.
Example: Suppose you're in a buffer named apple
and there is another buffer named banana
in a different tab. You highlight the text you want to send to banana
(say, a line that has text "asdf", and then type :'<,'>append ban<TAB>
and vim autocompletes the text to :append banana
. After pressing return, vim cuts the string "asdf" from apple
and appends it to the end of banana
.
The closest I've come is :'<,'>!cat >> banana
; however, this only works if banana is in the same working directory as apple, and it fails to autocomplete with existing buffer names.
Is there a way to construct a vim script/viml function that does this?