vscode-jupyter
vscode-jupyter copied to clipboard
Format cell on run like the nb_black extension does.
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.
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.
Thanks! Since black catches syntax errors, it's kinda related to this too, no? https://github.com/microsoft/vscode-jupyter/issues/1482
+1 code format inside cell is the last reason I still keep jupyter-lab on my system.
Just FYI, black now supports Jupyter Notebooks and even has a black.format_cell
function, so that could help here
That would be very helpful indeed! Thanks for considering!
Any news regarding this?
I would personally prefer to have the formatting done on save, and not when running a cell.
Sorry but it's not planned at the moment.
Spent 1/2 hour trying to figure out why it's not working... some hint in the config section would be nice.
Could you please reconsider this again?
Cheers.
You can add the "notebook.formatOnSave.enabled": true
setting as found here.
This feature will be in the next insiders build, and can be enabled by adding the following into your settings json:
"notebook.formatOnCellExecution": true
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: @.***>