Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Bug fix for URL highlighting (trailing punctuation)

The "syntax region" command isn't very well suited to highlighting URLs.
The only reason I used it was so I could hide URL schemes using Vim's
conceal feature. I've now changed it to a "syntax match" command which
makes it easier to deal with trailing punctuation, i.e. a trailing
slash after a URL should be included in the match but other punctuation
should be ignored (dots, commas, quotes, etc.)
  • Loading branch information...
commit 79eea085d726ba9f98644865217758cce0eafe65 1 parent bd4d971
@xolox authored
Showing with 8 additions and 11 deletions.
  1. +2 −2 notes.vim
  2. +6 −9 syntax.vim
4 notes.vim
@@ -1,9 +1,9 @@
" Vim plug-in
" Author: Peter Odding <>
-" Last Change: December 23, 2010
+" Last Change: December 24, 2010
" URL:
" License: MIT
-" Version: 0.7.8
+" Version: 0.7.9
" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3375 1 :AutoInstall:
15 syntax.vim
@@ -1,6 +1,6 @@
" Vim syntax script
" Author: Peter Odding <>
-" Last Change: December 22, 2010
+" Last Change: December 24, 2010
" URL:
" Note: This file is encoded in UTF-8 including a byte order mark so
@@ -54,18 +54,15 @@ syntax cluster notesInline add=notesBold
highlight notesBold gui=bold
" Highlight domain names, URLs, e-mail addresses and filenames. {{{2
-syntax match notesTextURL @\<www\.\(\S*\w\)\+[/?#]\?@
+syntax match notesTextURL @\<www\.\(\S*\w\)\+/\?@
syntax cluster notesInline add=notesTextURL
highlight def link notesTextURL Underlined
+syntax match notesRealURL @\<\(mailto:\|javascript:\|\w\{3,}://\)\(\S*\w\)\+/\?@
+syntax cluster notesInline add=notesRealURL
+highlight def link notesRealURL Underlined
if has('conceal')
- syntax region notesFullURL matchgroup=notesURLScheme start=@\<\(mailto:\|javascript:\|\w\{3,}://\)@ end=/\([[:punct:]]\s\|\s\|$\)\@=/ concealends
- highlight def link notesURLScheme notesFullURL
- syntax match notesFullURL @\<\(mailto:\|javascript:\|\w\{3,}://\)\(\S*\w\)\+[/?#]\?@
+ syntax match notesUrlScheme @\(mailto:\|javascript:\|\w\{3,}://\)@ contained containedin=notesRealURL conceal
-syntax cluster notesInline add=notesFullURL
-highlight def link notesFullURL Underlined
syntax match notesEmailAddr /\<\w[^@ \t\r]*\w@\w[^@ \t\r]\+\w\>/
syntax cluster notesInline add=notesEmailAddr
highlight def link notesEmailAddr Underlined

0 comments on commit 79eea08

Please sign in to comment.
Something went wrong with that request. Please try again.