treefmt icon indicating copy to clipboard operation
treefmt copied to clipboard

Range formatting

Open veselyn opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe.

I would like to be able to format specific ranges of files.

For example, given the following file:

if true; then
fi

if false;       then
  fi

I would be able to format only the second if statement.

Describe the solution you'd like

Two parameters for the CLI:

  • --range-start to specify from which line of the file to start, preferably starting from 0
  • --range-end to specify until which line to format

Additional context

A popular code editor, Neovim, has support for range formatting but it requires the formatter to have options to specify the range.

veselyn avatar Mar 25 '24 13:03 veselyn

If I understand correctly, this would be only used in conjunction with --stdin mode?

brianmcgee avatar Aug 19 '24 15:08 brianmcgee

If I understand correctly, this would be only used in conjunction with --stdin mode?

Correct! :)

veselyn avatar Aug 19 '24 16:08 veselyn

Should be easy enough to add :slightly_smiling_face:

brianmcgee avatar Aug 19 '24 16:08 brianmcgee