Feature request re: Stan support in RStudio 1.2

Apologies for the cross-posting; I posted the following comment on the RStudio blog announcement for Stan support in v1.2 but haven't gotten a response, and I'm not sure if anyone is still checking there. I hope this is the appropriate subforum.

As a scientist who does a lot of Bayesian modeling, RStudio and Stan have both been game-changers, so this is great. Thanks to everyone involved.

However, there are two features of RStudio's Stan code editor (in previous versions, and in the v1.2 preview release) that are deal-breakers for me:

(1) No auto-indent, like that available for R code with Ctrl-I.
(2) No option to turn off line-wrapping. I realize the Stan team encourages the use of line breaks, and I do try to keep lines short enough to fit in the editor pane, but sometimes it's just not practical, especially when working on a laptop. I find it much easier to use the horizontal scrollbar when necessary, whereas soft-wrapping makes the code nearly unreadable. I think this behavior should be up to the user, just like it is for R scripts.

My workaround has been, and will continue to be, editing Stan code using the R script editor format, but that means missing out on all the great features described in this announcement. I'm not alone here, either -- several of my colleagues have the same issues.

Any chance of getting these two things changed for the v1.2 final release? Pretty please?

With the v1.2 release seemingly approaching, and with this thread soon to be closed for inactivity, I'm bumping this in hopes of getting a reply as to whether these minor (but crucial, IMO) tweaks to the Stan editor format might be possible. If not, so be it, but I was hoping someone from the RStudio team would see this and respond.

Again, thanks for a generally fantastic product.

I think these would be great feature requests to give the IDE team.

Here's their guide to posing these
https://github.com/rstudio/rstudio/wiki/Writing-Good-Feature-Requests

I think this might make for two separate feature requests. The first is straightforward, but the later seems to have had a lot of discussion on over the years on support.rstudio.com and in github issues. I think you are asking for specific and different soft-wrapping behavior given the R Markdown code-chunk type. That is, maybe stan chunks don't have wrapping but R chunks do?

Thanks! I had a feeling this might not be the right place to ask, but there do seem to be many similar questions / requests in this forum.

Re soft-wrapping, none of this is about RMarkdown or code chunks at all; just the behavior in the editor pane when the format "Stan" is selected from the dropdown menu of file types. When the format is "R script", the user can choose whether soft-wrapping is on or off (via the Editing tab of Global Options: Code), but when the format is "Stan", that check-box has no effect and soft-wrapping is always on. I would prefer that it be always off, or that it be under user control.

Edit: Looks like the devs were listening after all, and already filed an issue. Thank you! I look forward to these improvements in conjunction with the forthcoming Stan support in v1.2!

1 Like

You can also test these by downloading the v1.2 preview release. :slight_smile:

Very nice!

I have noticed a few unexpected behaviors, though:

  • Auto-indent for Stan files doesn't work the same way it does for R scripts. Expressions following for and if statements are only auto-indented if those expressions are enclosed in curly braces. So, for example, auto-indent in a Stan file would produce the following:
for(i in 1:N) {
  x[i] = i;
}
for(i in 1:N)
x[i] = i;

whereas in an R script, both would be properly indented.

  • The Document Outline pane showing the Stan code blocks (which is great) changes in a presumably unintended way as the code is edited and saved. If, say, I make a change in the transformed parameters block and save it, the preceding blocks (functions, data, transformed data, parameters) all disappear from the outline and only the current and subsequent blocks (transformed parameters, model, generated quantities) remain. If I then go to an earlier block and do the same thing, the missing lines in the outline reappear. Actually, I haven't quite figured out the sequence of edits and saves that causes this, but it happens routinely.

I can live with these issues, though. I mean, next I'll be complaining that the old logo was better! :wink:

Thanks for taking the time to test! Would you mind filing this as a bug report at https://github.com/rstudio/rstudio/issues, so we don't lose track of this down the line?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.