开发者

Emacs align-regexp working with "="

开发者 https://www.devze.com 2023-01-15 13:39 出处:网络
Example code: f x \"s\" == x = 1 otherwise = 0 I can see the regex开发者_高级运维p as \"match the equals sign when surrounded by whitespace characters\". However, \\s-+=\\s-+ doesn\'t work (\\s

Example code:

f x
  | "s" == x = 1
  | otherwise = 0

I can see the regex开发者_高级运维p as "match the equals sign when surrounded by whitespace characters". However, \s-+=\s-+ doesn't work (\s-+ is the pattern for 1+ whitespace) because it ends up inserting an extra space before the equals sign. I need a pattern that says "match empty string when there is whitespace here", but not sure how to do this?


This works for me:

C-u M-x align-regexp RET \(\s-+\)=\s- RET RET RET n

Note the '+' inside the parens, the default has '*'

0

精彩评论

暂无评论...
验证码 换一张
取 消