On 20/08/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.
The script will only work on Windows anyway, because each OS has its own way (when it has one) of opening a given non-executable file in the default handler program for that filetype. There's no portable way to do that, you've got to use, for each OS, whatever works in that OS. Windows has cmd /c, so in Windows you can use that. You can even test if has('win32') || has('win64') !start cmd /c % endif Or you might try using system() instead or :! to see if it avoids the "hanging DOS box". Best regards, Tony. -- default, n.: [Possibly from Black English "De fault wid dis system is you, mon."] The vain attempt to avoid errors by inactivity. "Nothing will come of nothing: speak again." -- King Lear. -- Stan Kelly-Bootle, "The Devil's DP Dictionary" --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---