How to disable code-formatting for certain lines / blocks?

OPEN

How do you mark some lines to be skipped from using the Format Document command?

I don't want to touch the dart.lineLength , I just want to prevent a few specific lines from formatting to keep some code on the same lines instead of splitting them up.

I tried using this at the end of my lines:

some-code-here... // dart format off

And wrap them around with:

// dart format off
some-code-here...
// dart format on

But no dice.

I'm using Cursor, but essentially the extension (I'm assuming?) would be the same as the one used by VS Code.

I'm using the Dart extension version 3.118.1.

Posted Sep 5, 2025, 10:10 AM UTC

33
Loading comments…