-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support syntax highlighting for bracketed expression in fmt string #1634
Conversation
Thanks! Seems to work well judging from looking at The only pattersn that don't work yet are:
I tried to fix it, but leaning toothpick syndrome hurts by brain at this hour. I think we can make this more readable by some strategic insertions of I also wonder if there's a good way to split this across multiple lines, preferably with comments like in Python or Ruby:
That would make it much easier to maintain! |
I will take a look at those and learn to run the units as well. Thanks for the feedback, I'll try to update this PR with those changes as soon as a I can. |
Here's the best I could come up with:
Vim is very finicky about where you can place the Maybe a better solution is to use string concatenation (untested):
|
e8688eb
to
7e96300
Compare
Took your suggestion for doing multi-line continuation and added comments. I think everything in I'm not familiar enough with the \v option in vim, so I punted on doing that for now. |
Thanks! Works well, and much more readable/maintainable like this, even though it's still a long/ugly regex :-) |
Nice addition 👍 |
Per the go docs for the fmt package, there is a bracket expression that is supported in format strings.
For example,
fmt.Sprintf("%[2]d %[1]d\n", 11, 22) fmt.Sprintf("%[3]*.[2]*[1]f", 12.0, 2, 6) fmt.Sprintf("%d %d %#[1]x %#x", 16, 17)
Should all be valid syntax highlighted format strings.