Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6561891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:38:37+00:00 2026-05-25T13:38:37+00:00

When I write html in MacVim I keep the same file open in a

  • 0

When I write html in MacVim I keep the same file open in a web browser so that I can examine the html output. One of the things I dislike about this method is that I constantly have to leave vim, go to the browser, and reload the html to see the updates. Is there a more elegant solution with vim that will dynamically update html ouput as it is typed in vim? I seem to recall that Textmate could do this? Thanks.

UPDATE:
I found the video I was trying to remember. You can find it here:

http://files.fletcherpenney.net/TextMate-Preview.mov

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:38:37+00:00Added an answer on May 25, 2026 at 1:38 pm

    Add this to your .vimrc:

    " Refresh WebKit
    nnoremap \r :Refresh<CR>
    
    command! Refresh call RefreshWebKit() 
    
    function! RefreshWebKit()
        silent !osascript -e 'tell application "WebKit"'
                        \ -e '  set p_url to URL of current tab of front window'
                        \ -e '  set URL of current tab of front window to p_url'
                        \ -e 'end tell'
    endfunction
    

    This will create a map, a command and a function. I could have joined them, but
    this way it it’s more clear and I can reuse the function in other places.

    The function calls a little AppleScript to set the URL of frontmost tab again,
    thus refreshing it. This will work under Safari and WebKit, but I can’t
    guarantee that it works with other browsers. If not, google “refresh {browser}
    applescript” and use a different script.

    The map just calls the command, which calls the function. So you can write your
    file and use it to refresh the browser without leaving Vim. Equally, use
    :Refresh to do the same.

    Note that you may want to change some things:

    • The map itself, I used \r, use whatever you feel comfortable with.
    • The name of the function, if you want to avoid collisions with other existing
      functions
    • The browser. Here I used WebKit, which is not Safari. It’s the nightly build
      of WebKit itself. Use Chrome, Firefox, or any other name (with the respective
      changes)

    A quick note: the extra -e options passed to the program are just for the sake
    of readability. Do it in the fashion you want.


    Take a look also in auto-commands (check :h autocmd.txt). This will let you
    do it in a more automatized way like:

    :autocmd BufWrite *.html Refresh
    

    This will call :Refresh every time you write a buffer for .html files. There
    are also events for inserted text and so on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’d like to be able to open a text/html file and write its contents
What editor or IDE can I use to write html code? I mean that
I want to write Html format, but I can not even get a simple
I'm looking to write a html sanitiser, and obviously to test/prove that it works
QA tester was reading HTML/JS code to write a functional test of a web
How can we write html tidy coding only for inserting closing tag in the
I have a requirement to write HTML to the file system and I was
I have whole page HTML in my database and i want write that html
i am having trouble. i write HTML and jQuery and set same name attribute
The marketing people want to have the ability to write direct inline HTML in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.