zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
47.11k stars 2.71k forks source link

Support formatting a code block / selection #5026

Open shekharnwagh opened 1 year ago

shekharnwagh commented 1 year ago

Check for existing issues

Describe the feature

VSCode/IntelliJ has the option to select a block of code and format only that instead of the whole file. This would be helpful if you only want to reformat newly added/altered code instead of the whole file to avoid creating big diffs.

If applicable, add mockups / screenshots to help present your vision of the feature

Screenshot 2023-01-28 at 2 11 11 PM
ElijahBus commented 1 month ago

Certainly a needed feature 👍

sangelxyz commented 2 weeks ago

Also neovim has it, you use = to format the selection, very handy feature which is missing?

kurtpeniket commented 2 weeks ago

Also neovim has it, you use = to format the selection, very handy feature which is missing?

@sangelxyz , I have this in my keymap.json to emulate what I'm used to in nvim:

  {
    "context": "Editor && VimControl && !VimWaiting && !menu",
    "bindings": {
      "space =": "editor::Format",
    }
  }

but that formats the entire file as far as I know and not just the visual block like in vim unfortunately.