vscode-jupyter icon indicating copy to clipboard operation
vscode-jupyter copied to clipboard

Format cell on run like the nb_black extension does.

Open nickeubank opened this issue 3 years ago • 8 comments

One of my favorite features of vscode (and other good editors) is format on save. Obviously that's not feasible for notebooks because they aren't linear and so a formatter would struggle if it tried to parse everything every time the notebook was saved. But there is a solution that's like format on save for notebooks: format on run.

Now that notebook cells can be formatted, would it be possible to create a setting where each cell is formatted when it's run? It's already available in regular jupyter notebooks thanks to nb_black, and I'd love to see it in VS code notebooks.

nickeubank avatar Aug 10 '21 23:08 nickeubank

Thanks for the suggestion. We'll look at it in our weekly triage. It will probably need a bunch of upvotes before it's considered.

rchiodo avatar Aug 10 '21 23:08 rchiodo

Thanks! Since black catches syntax errors, it's kinda related to this too, no? https://github.com/microsoft/vscode-jupyter/issues/1482

nickeubank avatar Aug 11 '21 00:08 nickeubank

+1 code format inside cell is the last reason I still keep jupyter-lab on my system.

dwSun avatar Aug 11 '21 03:08 dwSun

That would be very helpful indeed! Thanks for considering!

jucor avatar Oct 09 '21 09:10 jucor

Any news regarding this?

I would personally prefer to have the formatting done on save, and not when running a cell.

alonme avatar Apr 19 '22 19:04 alonme

Sorry but it's not planned at the moment.

rchiodo avatar Apr 19 '22 20:04 rchiodo

Spent 1/2 hour trying to figure out why it's not working... some hint in the config section would be nice.

movy avatar Sep 18 '22 10:09 movy

Could you please reconsider this again?

Cheers.

smoochy avatar Feb 20 '23 20:02 smoochy

You can add the "notebook.formatOnSave.enabled": true setting as found here.

sa2812 avatar Apr 27 '23 14:04 sa2812

This feature will be in the next insiders build, and can be enabled by adding the following into your settings json: "notebook.formatOnCellExecution": true

Yoyokrazy avatar May 22 '23 20:05 Yoyokrazy

Awesome, thanks!

On Mon, May 22, 2023, 21:52 Michael Lively @.***> wrote:

This feature will be in the next insiders build, and can be enabled by adding the following into your settings json: "notebook.formatOnCellExecution": true

— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-jupyter/issues/7058#issuecomment-1557973870, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFBERMIFG7HDLZOJO7EZJTXHPGYRANCNFSM5B47I5OQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jucor avatar May 22 '23 20:05 jucor