Dimitriy V. Masterov wrote:
I am trying to find a way to copy text that I've highlighted with the
mouse to a temporary file with a .do extension, so that I might use it
in the script below, and then delete it. I am not sure how to proceed
from here. Any advice would be greatly appreciated.
fun! RunLines()
!start "C:\Program Files\Scripts\rundo.exe" "C:/.../tempfile.do"<Enter>
endfun
:map <F9> :<C-U>call RunLines() <Enter>
:imap <F9> <Esc>:<C-U>call RunLines() <Enter>
The quick-and-dirty solution would be to yank the highlighted text, then
put it in the new file. Example:
y
:let tempfile = $TEMP . "/tempname.do"
:exe "new" tempfile
:0put
:x
" define a command to run the script
command -nargs=0 -bar RunLines
\ exe "!start C:\PROGRA~1\Scripts\rundo.exe"
\ . g:tempfile
" define mappings to run the command
map <F9> :RunLines<CR>
imap <F9> <C-O>:RunLines<CR>
" (optional) setup an autocmd for shutdown cleanup
au VimLeave * exe "!del -y" tempfile
Best regards,
Tony.