Scattered Like Birds

Search

Styles

   
   
   

Blogmarks

Movies

Recent Articles

Blogroll

Movie Quote

No more movie quotes!

My Other Blogs

About

CSS Site Signature: #www-samrowe-com

This blog is "powered by" Parasite, which is a PHP/PEAR::DB blog written by yours truly.

On good days, Parasite supports Ian Hickson & Stuar Langridge's Pingback1.0. It hasn't been a good day in a VERY long time and likely never will be again!

The stuff that Parasite doesn't do for me is done in vim.

Being standards compliant is the only attempt this site makes at being IE friendly.

You can email me using the initials of this blog at this domain.

Conversation A.D. 33

One: Have you heard the news?
Two: No, what's happened?
One: The good Lord has come down in human form and had himself killed!
Two: To what end?
One: With this act, the Devil is hoodwinked and all humanity saved!
Two: Gosh, that's simply lovely.

Make Vim work for you
Wednesday Nov 12 3:06pm 2003
by Sam

I wrote a little vim function (my first) that I thought others might find useful. It's a little clunky, but it works :)

function! WebMe()
    let s:browser = 'w3m'
    let s:prot = 'http://'
 
    let s:ps = '/home/user/public_html/'
    let s:dm = '/www/deadman/htdocs/'
    let s:sr = '/www/samrowe/htdocs/'
    let s:un = '/www/unspeakable/htdocs/'
    let s:pslen = strlen(s:ps)
    let s:dmlen = strlen(s:dm)
    let s:srlen = strlen(s:sr)
    let s:unlen = strlen(s:un)
 
    let s:this = expand("%:p")
 
    if s:this =~ strpart(s:ps,0,s:pslen)
        let s:domain = 'www.1pof.org/'
        let s:that = strpart(s:this,s:pslen)

    elseif s:this =~ strpart(s:dm,0,s:dmlen)
        let s:domain = 'www.deadman.org/'
        let s:that = strpart(s:this,s:dmlen)
               
    elseif s:this =~ strpart(s:sr,0,s:srlen)
        let s:domain = 'www.samrowe.com/'
        let s:that = strpart(s:this,s:srlen)
               
    elseif s:this =~ strpart(s:un,0,s:unlen)
        let s:domain = 'www.unspeakable.net/'
        let s:that = strpart(s:this,s:unlen)
    else
        return
    endif
    let $webcommand = s:browser .' '. s:prot . s:domain . s:that
    !$webcommand
endfunction

map <F2> :call WebMe()<cr>

I have all of that stuff in my ~/.vimrc and basically, it ~intelligently knows which domain to visit to see the file I'm currently editing. Since I almost always edit files that are generated by PHP, I want to view the parsed file, rather than just calling 'w3m myfile.php'.

The clunky part, obviously, is having to create all of those stupid variables, but I couldn't see an easier way to do it in vimscript.

Home