> You can even do it in one step ;)
>
> :call append('.', map(readfile('/tmp/foobar'), '"Attach:
> ".substitute(v:val," ",''\\ '',"g")'))
This seems to be perfect. So here is my final .vimrc script:
| " mutt: insert attachment with ranger
| fun! RangerMuttAttach()
| if filereadable('/tmp/chosendir')
| silent !ranger --choosefiles=/tmp/chosenfiles
--choosedir=/tmp/chosendir "$(cat /tmp/chosendir)"
| else
| silent !ranger --choosefiles=/tmp/chosenfiles
--choosedir=/tmp/chosendir
| endif
| if filereadable('/tmp/chosenfiles')
| call append('.', map(readfile('/tmp/chosenfiles'), '"Attach:
".substitute(v:val," ",''\\ '',"g")'))
| call system('rm /tmp/chosenfiles')
| endif
| redraw!
| endfun
| map <C-a> magg/Reply-To<CR><ESC>:call RangerMuttAttach()<CR>`a
| imap <C-a> <ESC>magg/Reply-To<CR><ESC>:call RangerMuttAttach()<CR>`aa
Thank you!