Vim - open current file in web browser - Editors

This is a discussion on Vim - open current file in web browser - Editors ; Greetings: I'm writing some asp / vbscript in vim and I'd like to view the file I'm currently editing in vim. I'm sure this is easy, but I've looked through the help files and Googled the topic and haven't found ...

+ Reply to Thread
Results 1 to 6 of 6

Vim - open current file in web browser

  1. Default Vim - open current file in web browser

    Greetings:

    I'm writing some asp / vbscript in vim and I'd like to view the file
    I'm currently editing in vim. I'm sure this is easy, but I've looked
    through the help files and Googled the topic and haven't found
    anything.

    TIA

    Keith


  2. Default Re: Vim - open current file in web browser

    Keith wrote:
    > Greetings:
    >
    > I'm writing some asp / vbscript in vim and I'd like to view the file
    > I'm currently editing in vim. I'm sure this is easy, but I've looked
    > through the help files and Googled the topic and haven't found
    > anything.
    >
    > TIA
    >
    > Keith
    >


    It depends on your browser ( How do you start it and instantly have it open a given url ? )
    and your operating system (How do you run a command in the background ? ).

    Under *nix with firefox (and most othe browsers ) this should work :
    :!firefox % &
    vim expands '%' to the filename of the buffer.
    For the general idea read
    ':h :!'.

    -ap

  3. Default Re: Vim - open current file in web browser

    On Oct 22, 1:28 pm, muede73 <mued...@gmx.de> wrote:
    >
    > It depends on your browser ( How do you start it and instantly have it open a given url ? )
    > and your operating system (How do you run a command in the background ? ).
    >
    > Under *nix with firefox (and most othe browsers ) this should work :
    > :!firefox % &
    > vim expands '%' to the filename of the buffer.
    > For the general idea read
    > ':
    >
    > -ap


    Thanks for your reply. I'm running gVim 7.1 on WinXP. (Sorry for not
    providing this info in my first post.) I'm trying to load the current
    file into IE (FireFox doesn't support VBScript). In NotePad++ I used
    to just select Run > Launch in IE. I tried this:

    :!iexplore % &

    but XP didn't recognize i as a valid internal or external command.
    Does the IE folder need to be in the path for this to work, or can I
    provide the path in the command? I'm also unclear about this approach,
    since I don't want to filter anything, just call the external app.
    Finally, what does the & do? The helpfile says it repeats the last
    substitution.

    Thanks again for taking the time to write back.

    Keith


  4. Default Re: Vim - open current file in web browser

    Keith wrote:
    > On Oct 22, 1:28 pm, muede73 <mued...@gmx.de> wrote:
    >
    >>It depends on your browser ( How do you start it and instantly have it open a given url ? )
    >>and your operating system (How do you run a command in the background ? ).
    >>
    >>Under *nix with firefox (and most othe browsers ) this should work :
    >>:!firefox % &
    >>vim expands '%' to the filename of the buffer.
    >>For the general idea read
    >>':
    >>
    >>-ap

    >
    >
    > Thanks for your reply. I'm running gVim 7.1 on WinXP. (Sorry for not
    > providing this info in my first post.) I'm trying to load the current
    > file into IE (FireFox doesn't support VBScript). In NotePad++ I used
    > to just select Run > Launch in IE. I tried this:
    >
    > :!iexplore % &
    >
    > but XP didn't recognize i as a valid internal or external command.
    > Does the IE folder need to be in the path for this to work, or can I
    > provide the path in the command? I'm also unclear about this approach,
    > since I don't want to filter anything, just call the external app.
    > Finally, what does the & do? The helpfile says it repeats the last
    > substitution.


    Take a look at ':h E34' ( which is ':!' and not '!', neither ':[range]!' ).
    Everything after the '!' is a system command, except for some characters,
    which vim will expand before execution.While '%' is one of them, '&'
    is not.(The last one '&' tells a *nix to run the command in the background.)

    I think the executable (iexplore.exe ? ) would have to be in your %PATH,
    or it would have to be a fully qualified name ('c:/...') .

    I also think, that someone with actual win32 experience could be of more service.
    Maybe you want to consider reposting this on vim_use@googlgroups.com,
    which requires subscription, but will also give you a quick response, since
    there are many people on that list,willing to answer this kind of questions.

    -ap

    >
    > Thanks again for taking the time to write back.
    >
    > Keith
    >


  5. Default Re: Vim - open current file in web browser

    On Mon, 22 Oct 2007 07:23:45 -0700, Keith wrote:
    >
    > I'm writing some asp / vbscript in vim and I'd like to view the file
    > I'm currently editing in vim. I'm sure this is easy, but I've looked
    > through the help files and Googled the topic and haven't found
    > anything.


    Here's an excerpt of what we use in Cream:

    let file = 'C:\myfile.html'
    " 95/98/ME
    if has("win95")
    let cmd = 'silent! !command /c start "' . file . '"'
    " NT/2K/XP
    else
    let cmd = 'silent! !cmd /c "' . file . '"'
    endif

    Obtaining a complete and valid path is a bit more complicated, you
    have to convert Vim's internally obtained paths (such as with
    confirm() ) for the OS depending on your &shellslash setting. This
    entails correcting path seperators, spaces, UNC server names, etc.


    --
    Steve Hall [ digitect dancingpaper com ]
    :: Cream... usability for Vim
    :: http://cream.sourceforge.net

  6. Default Re: Vim - open current file in web browser

    On Oct 22, 5:39 pm, digitect <digitec...@SPAMdancingpaper.com> wrote:
    > On Mon, 22 Oct 2007 07:23:45 -0700, Keith wrote:
    >
    > > I'm writing some asp / vbscript in vim and I'd like to view the file
    > > I'm currently editing in vim. I'm sure this is easy, but I've looked
    > > through the help files and Googled the topic and haven't found
    > > anything.

    >
    > Here's an excerpt of what we use in Cream:
    >
    > let file = 'C:\myfile.html'
    > " 95/98/ME
    > if has("win95")
    > let cmd = 'silent! !command /c start "' . file . '"'
    > " NT/2K/XP
    > else
    > let cmd = 'silent! !cmd /c "' . file . '"'
    > endif
    >
    > Obtaining a complete and valid path is a bit more complicated, you
    > have to convert Vim's internally obtained paths (such as with
    > confirm() ) for the OS depending on your &shellslash setting. This
    > entails correcting path seperators, spaces, UNC server names, etc.
    >
    > --
    > Steve Hall [ digitect dancingpaper com ]
    > :: Cream... usability for Vim
    > :: http://cream.sourceforge.net


    Thanks for the tips. I'll give them a try. (I also downloaded Cream
    and will check it out.)

    Keith


+ Reply to Thread

Similar Threads

  1. Replies: 9
    Last Post: 11-16-2007, 05:36 PM