Vim Tips Wiki
No edit summary
No edit summary
Line 3: Line 3:
 
==Improvements==
 
==Improvements==
   
Often I got urls in the format <code>(http://www.vim.org)</code>. Urls with braces around are not correctly recognized.
+
Often I got urls in the format <code>(http://www.vim.org)</code> or <code>(see http://www.vim.org)</code>. Urls with braces around are not correctly recognized.
   
 
Therefore I added following lines to utl.vim around line 407:
 
Therefore I added following lines to utl.vim around line 407:
Line 9: Line 9:
 
<code>
 
<code>
 
call Utl_trace("- end getting URL under cursor.",1,-1)
 
call Utl_trace("- end getting URL under cursor.",1,-1)
let tmpurl = matchstr(url, '^[(].*[)]$')
+
let tmpurl = matchstr(url, '^[(]\?.*[)]\+$')
 
if empty(tmpurl)
 
if empty(tmpurl)
 
return url
 
return url
 
else
 
else
 
call Utl_trace("- found braces around url, removing.",1,-1)
 
call Utl_trace("- found braces around url, removing.",1,-1)
return substitute(url, '^[(]\(.*\)[)]$', '\1', 'g')
+
return substitute(url, '^[(]\?\(.*\)[)]\+$', '\1', 'g')
 
endif
 
endif
 
</code>
 
</code>

Revision as of 09:32, 18 February 2013

Improvements

Often I got urls in the format (http://www.vim.org) or (see http://www.vim.org). Urls with braces around are not correctly recognized.

Therefore I added following lines to utl.vim around line 407:

   call Utl_trace("- end getting URL under cursor.",1,-1) 
   let tmpurl = matchstr(url, '^[(]\?.*[)]\+$')
   if empty(tmpurl)
     return url
   else
     call Utl_trace("- found braces around url, removing.",1,-1) 
     return substitute(url, '^[(]\?\(.*\)[)]\+$', '\1', 'g')
   endif