-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
how to split the parameters into different lines and keep them aligned? #57
Comments
formatR cannot do that... Reminder to self: update this post when this feature is implemented. |
I second adding this feature if possible, since this is the correct way to write functions with multi-line parameters |
I wouldn't say "it is the correct way", but it is definitely a favorable style to many people. I don't feel the implementation is easy, so I'll leave this task to contributors... |
I checked out the potential solutions before. It was definitely harder than I think: a basic parser understanding R syntax is needed, rather than any "text processing" logics... |
Exactly. You cannot do this only through regular expressions or any text processing techniques. A parser has to be involved. |
Hm, that sounds way above what I would be capable of doing. It seems that RStudio already implements this, but I am only asking because I have been trying to write R code in Atom for a project that I have to use a remote cluster for. It seems that the atom-beautify package implements formatR for formatting R code |
If someone can figure out the RStudio magic, and it turns out not be super difficult to implement in pure R, I'd welcome a pull request. Personally I don't have time or enough interest in this feature. |
It's this basically a duplicate of #53? |
@naught101 Yes. I can tell you that RStudio actually uses JavaScript to reformat the R code, so the magic cannot be directly ported to formatR. |
After using "format code" in the latest RStudio, the parameters of functions are split into different lines and kept aligned.
But I am unable to find the corresponding settings in
formatR
package. How to do it withformatR
?Consider the source code:
The desired formatted result (RStudio returns this):
The text was updated successfully, but these errors were encountered: