0

Sorry if this has already been asked, but I didn't quite find what I was looking for.

Is there a way to do syntax highlighting for the entire hyperlink in .txt files for Vim?

This is what I have so far

hi Hyperlink term=standout,bold ctermfg=Cyan
let m = matchadd("Hyperlink", "http://")
let m = matchadd("Hyperlink", "https://")
J-Win
  • 1,322
  • 16
  • 35
  • 1
    Maybe have a look at this questions [What is the best regular expression to check if a string is a valid URL?](https://stackoverflow.com/questions/161738/what-is-the-best-regular-expression-to-check-if-a-string-is-a-valid-url) or [What is a good regular expression to match a URL?](https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url). – Ralf Dec 31 '18 at 00:47

1 Answers1

1

See this amazing URL regexp in vim-highlighturl pligin.

I use a bit simpler regexp:

syntax match Hyperlink `\v<(((https?|ftp|gopher|telnet)://|(mailto|file|news|about|ed2k|irc|sip|magnet):)[^' \t<>"]+|(www|web|w3)[a-z0-9_-]*\.[a-z0-9._-]+\.[^' \t<>"]+)[a-z0-9/]`
phd
  • 82,685
  • 13
  • 120
  • 165