Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

different keyboard shortcuts for different styles #1221

Open
rinkjames opened this issue Jul 4, 2024 · 2 comments
Open

different keyboard shortcuts for different styles #1221

rinkjames opened this issue Jul 4, 2024 · 2 comments

Comments

@rinkjames
Copy link

rinkjames commented Jul 4, 2024

Hi, not sure if this is possible. Sometimes I'd like to retain the (lack of) line breaks for certain lines of R code, because I think it's easier to read. I've learned how to set the style using options(styler::tidyverse_style(scope = I(c('spaces','indention','tokens')))), but it would be great to have a dedicated keyboard shortcut for styling a selection of code with this specified style. Then I can use one shortcut for invoking style_selection with the default tidyverse style, and another keyboard shortcut for invoking style_selection with the no-breaks tidyverse style.

Possible?

@lorenzwalthert
Copy link
Collaborator

Hi, I am not sure that's easily possible due to {rstudioapi} current functionality. Technically, I think we could expose multiple addins and allow the user to parametrise each of them with a style guide (instead of relying on the options). Or make the behaviour of the styling addin dependent on some environment / option value. But I consider that out of scope for {styler.}. Also, consider using {codegrip}.

@rinkjames
Copy link
Author

Understood. Thanks for clarifying. I suppose I'll look into trying to achieve your first idea, with distinct addins for different styles that I can bind to different shortcuts. I looked at codegrip, but I didn't see anything that might be useful for this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants