On 20-Aug-08 16:16, Robert Webb wrote:
> Hi,
> 
> What's the best way (on Windows) to open a file from vim in whatever
> Windows normally uses to open that file?  For example, :!% will open
> the current file, but it leaves a DOS window handing around while the
> file is open, which requires a hit-enter to get rid of after closing
> the file.
> 
> You also can't use vim until the file is closed in the external
> program.  If I try ":!start %" to make them asynchronous, then it
> doesn't know how to open "%".  If :!% knows to use "cmd /c", shouldn't
> ":!start %" know the same thing?
> 
> The best way seems to be ":!start cmd /c %", but now the script will
> only work on Windows.  There's also an annoying DOS window hanging
> around in the background.  Any way to get rid of that?
> 
> I can't find a scripting function to open a given file however the OS
> sees fit.
> 
> Thanks,
> Rob.

Use ":silent ! start %"; the 'silent' will close the DOS window immediately. I 
use this
     map <Leader>x :silent ! start "1" "%:p"<CR>
to execute the current file. ':p' makes this independent from the CWD, the 
surrounding "" make it handle spaces. The "1" is the optional "title" argument 
to 'start'; I've read somewhere that sometimes 'start' may confuse the command 
for the title if the title is missing, so I keep that dummy title in there.

-- regards, ingo

/^-- Ingo Karkat -- /^-- /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui