interactive-align
interactive-align copied to clipboard
Example regexp
Nice package, thanks for putting this together.
In your example you use \(\s-*[0-9]+\)
I can't get that to work.
What works for me is if I go to group -1 and use \([0-9]+\)
What does the -*
do in your example? Is this some negation?
- \s is whitespace
- [0-9]+ is one or more number
Also posting all the steps in your gif as commands would be useful.
Thanks. It would be helpful if you provided some example text which you're trying to align.
In Emacs regular expressions, \s
must be followed by a character and it means "match a character with that syntax". The -
character stands for whitespace syntax class. Thus \s-*
means "match zero or more characters with whitespace syntax class". See Emacs manual for more information.
Hi another thanks from me for the package. I believe the above poster is trying to do something like this:
hi 0
what 1
who 2
how? 3
When using the built in emacs align-regexp you just need to do M-x align-regexp [0-9] RET
. Which would result in this:
hi 0
what 1
who 2
how? 3
This package it appears you have to do \(\s-+\)
which matches the whitespace giving the same effect. However if you delete that and put in [0-9]
it will not align the numbers. The question is why?
Hi @phoenixanimations,
The question is why?
When you call align-regexp
without a prefix argument, it automatically prepends \(\s-*\)
regexp to your expression. With a prefix argument, you have to provide the full regexp. This package also required you to be explicit.
I just pushed a commit which allows you to have the behavior you desire. What you need to do is this:
(setq ialign-implicit-regexp "\\(\s-*\\)")
Doing so will prepend that string to the regexp, if your regexp doesn't have a subgroup expression.
So with this you can align the text like in your example by just using the regexp [0-9]
.
Hope this solves your issue.
Oh wow, thank you. That's quite interesting and funny enough I might prefer the more explicit in that case.
Anyway thanks for the speedy response, and that definitely solves my problem.