function! ShortenURL() " This function grabs the url under the cursor, passes it to an " external script, grabs the shorter, returned url and replaces any " occurrences of the original URL. It then resets the cursor to the " starting posistion or the end of line if the column is now empty. " get the starting posistion let s:line = line(".") let s:colno = col(".") " this matches URLs! let s:lurl = expand('') "shorten the URL. this invokes the external command. let s:surl = system("masl.pl -n '" . s:lurl . "'") "now we have the long and short of it, replace long with short. execute "1,$s!" . s:lurl . "!" . s:surl . "!" " return us to where the command was invoked from. Will need later execute "call cursor(s:line, s:colno)" endfunction " This is the key that you use to call the function. noremap :call ShortenURL()