2

Full source here: http://www.vim.org/scripts/download_script.php?src_id=10391

The line is:

 silent %s/[^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>?@\^|~.]\@<=\\\([^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>\?@\^|~.]\)/λ\1/eg 

Someone please decipher this for me. The larger script is intended to unicode-ify some operators in Haskell into more familiar mathematical equivalents.

1
  • 2
    If this is "regular", I can't imagine what an irregular one would look like ;) Commented Jan 15, 2010 at 9:28

2 Answers 2

6

As the author of that line, I can translate. Complicated regular expressions are often 'write-only' and this relies on a vim regex extension.

The purpose of this is to make sure that it doesn't do the replacement of \ with a pretty printed λ in the middle of an operator like \\.

It checks to make sure that the character that precedes us in the buffer is not a valid operator symbol (the meaning of everything everything up to the \@<=). The \@<= is a 'zero width match look behind', which only succeeds if the stuff to the left of it occurs, but doesn't include it in the resulting match.

And then the \([^...]\) part checks to make sure that the stuff that follows us is a non-symbol as well, in which case, we match it, and then include it in the output thanks to the \1 in the result.

Note, this isn't perfect. Unfortunately, It will still replace backslashes inside of strings, but it works rather well.

Sign up to request clarification or add additional context in comments.

Comments

3

Full explanation for the line here: http://www.reddit.com/r/haskell/comments/8b0tf/haskell_unicode_cuteness_for_vim/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.