On 2018-01-27 02:29, slackyman76@gmail.com wrote:
> "PRINT TO PDF / PRINT AND OPEN TO CHROMIUM
> nmap <C-Home> :ha > newfile.ps <cr> :! ps2pdf newfile.ps<cr>:! rm
> newfile.ps<cr>
> nmap <C-S-Home> :ha > newfile.ps <cr> :! ps2pdf newfile.ps<cr>:!
> rm newfile.ps && chromium newfile.pdf<cr>
[snip]
> The only problem is that I have to rename "newfile" to a different
> name everytime. It's not a dramatic issue indeed, but...
>
> My questions:
>
> 1) Is there a more elegant or effective way to do the same things?
I guess it depends on which aspects you find inelegant of ineffective.
You could then take advantage of the 'printexpr' so ":hardcopy" alone
does everything you need. You can read the gritty details at
:help :hardcopy
:h 'printexpr'
:h pexpr-option
Particularly the bit in that last one about simplifying things with a
function.
Either way, wrapping it in a function might clean up the code,
something like (untested)
function! PrintFile(fname, ...)
call system('ps2pdf '. a:fname)
call delete(a:fname)
if a:0
call system('chromium ' . substitute(a:fname, '.ps$', '.pdf', '')
endif
return v:shell_error
endfunc
nmap <c-home> :set printexpr=PrintFile(v:fname_in) <bar> ha<cr>
nmap <c-s-home> :set printexpr=PrintFile(v:fname_in, 1) <bar> ha<cr>
By default my local copy of vim seems to name the "1.pdf", "3.pdf",
etc. Not sure if there's any sort of guaranteed in the sequence,
though I imagine they just auto-increment a bit. Not sure if it's
smart about the auto-generated names if more than one instance of vim
is running concurrently in the same directory.
You could also prompt for an output filename or auto-generate one
using the current timestamp:
function! PrintFile(fname, ...)
let l:outname=strftime('%Y%m%d_%H%M%S.pdf)
call system('ps2pdf '. a:fname . l:outname)
call delete(a:fname)
if a:0
call system('chromium ' . a:outname)
endif
return v:shell_error
endfunc
nmap <c-home> :set printexpr=PrintFile(v:fname_in) <bar> ha<cr>
nmap <c-s-home> :set printexpr=PrintFile(v:fname_in, 1) <bar> ha<cr>
> 2) Is there a way to open an email address from VIM and land in
> Gmail without creating a PDF? In Vim I open urls using gx but it
> doesn't work with email addresses.
Sorry, can't help much here as this is a Gmail-URL and browser sort
of thing external to vim.
-tim
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment