Skip to content

Add shortcut to run rustfmt #844

@pseyfert

Description

@pseyfert

I think it would be nice if one could run rustfmt from a keyboard shortcut, similar to ctrl+return to run code, or ctrl+F9 on compiler-explorer.org.

Activity

added
enhancementSomething new the playground could do
help wantedNot immediately going to be prioritized — ask for mentoring instructions!
on Sep 19, 2022
shepmaster

shepmaster commented on Sep 19, 2022

@shepmaster
Member

This was something we had discussed a long while ago, and I'm generally in favor. Some thoughts:

  1. We should do it for all the tools
  2. We should show the shortcuts in the tools menu:
    image
  3. We should be able to use these shortcuts both when the cursor is and is not focused on the editor component.
  4. We should think about making them comfortable for both macOS vs Linux/Windows users.
ian-h-chamberlain

ian-h-chamberlain commented on Nov 16, 2022

@ian-h-chamberlain

Another nice-to-have that's related to this would be vim-mode shortcuts for the same actions. For most of them perhaps just a command like :expand-macros or something would work, but for formatting it might also be nice to set vim's formatprg if possible, so that gq would invoke rustfmt as well (not sure if this is possible with codemirror, it might require a bit of extra plumbing or not really be worth it). Similar could be = and equalprg although which to use seems like a personal preference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething new the playground could dohelp wantedNot immediately going to be prioritized — ask for mentoring instructions!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @shepmaster@pseyfert@ian-h-chamberlain

      Issue actions

        Add shortcut to run rustfmt · Issue #844 · rust-lang/rust-playground