34

VS Code recently added the ability to work with Jupyter Notebooks (.ipynb files), this is to say it renders them as notebooks and not the underlying text.

The problem I'm running into is I want to make some edits on the raw text rather than the "notebook" but I can't figure out how to show it as a text file the way any other editor would.

Is there a way to toggle between the views?

Grokify
  • 15,092
  • 6
  • 60
  • 81
user1816847
  • 1,877
  • 3
  • 17
  • 29

7 Answers7

24

Disable automatically opening *.ipynb files in Notebook Editor

To make sure the Jupyter notebooks don't open in the Notebook Editor automatically, make sure to disable this settings. (Command Palette -> Settings)

OR

In the User or Workspace settings.json, add the following the root json - "jupyter.useNotebookEditor": false

To toggle between the Notebook Editor and Raw Text Mode Editing

There is an option/command called Reopen Editor with..., which will provide you options to open the *.ipynb file in text mode.

You trigger this by performing a Right Click on the Editor Tab (Editor Title Bar) or Command Palette -> Reopen Editor with...

PS: I have the Jupyter extension (v2020.12.414227025)

Libin Varghese
  • 1,506
  • 13
  • 19
17

Open: File > Preferences > Settings

Search ipynb and deselect the following:

enter image description here

saccodd
  • 972
  • 9
  • 23
  • 2
    If visual studio code does a mess, as it usually does, and this does not work, just rename the file to another extension, such as `.txt` and then read it. – Eduardo Pignatelli Aug 17 '21 at 09:21
6

Other answers didn't work for me recently. I found no "use notebook editor" option under preferences, perhaps vs code has reorganized recently. Instead I found the following solution. Right click on an *.ipynb file tab to get the context menu, and click "Reopen Editor With..." as pictured below.

enter image description here

Then on the following popup click "configure default editor for .ipynb", and then click on the text editor as seen below:

enter image description here

And viola. The default settings have been changed.

aquirdturtle
  • 2,038
  • 26
  • 20
5

I think the fastest way is to rename the file.

Just press F2 (or return for mac) while selecting the file in the vscode explorer, then rename from my-notebook.ipynb to my-notebook.json, because jupyter ipynb files are regular json files

UselesssCat
  • 2,248
  • 4
  • 20
  • 35
3

(Similar to aquirdturtle's answer)
What about

On the left side explorer

Right Click on file -> Open With -> Text Editor

erikizan
  • 33
  • 3
1

Create .json file and paste the notebook json in there, save the file and then rename the extension to .ipynb and it will open in the jupyter editor

irie
  • 21
  • 2
-1

Set the setting

"files.associations": {
  "*.ipynb": "text"
}

Or try click on the Status Bar field that shows the Language Mode of the file in the lower right.

Use the command: Change Language Mode

rioV8
  • 24,506
  • 3
  • 32
  • 49
  • there is no language mode in the status bar and using the command pallet it says there's "no text editor active at this time" which I suspect is because it's rendering a notebook using presumably a built in browser. Changing file associations doesn't work either. – user1816847 Apr 08 '20 at 00:40
  • 1
    @user1816847 rename the file to .txt and open with VSC – rioV8 Apr 08 '20 at 00:52
  • hmm yes this is what i'm trying to avoid though :( – user1816847 Apr 08 '20 at 01:00
  • @user1816847 I used notepad++ to edit .ipynb files, search settings for `ipynb` and unmark the open in Notebook editor – rioV8 Apr 08 '20 at 02:53
  • yeah :( I added sublime text into my work flow to do the one thing i need to do but i'm not happy about adding tools. Hopefully there will be a way to turn it off in VSCode. – user1816847 Apr 08 '20 at 03:13
  • @user1816847 don't you have vi on your machine or gedit or nano? – rioV8 Apr 08 '20 at 09:04
  • yes. I've been a vim user for the last 25 years. There are plenty of workarounds for what I want but that's a bit divergent from my original question. and keeping everything i need to do in vscode is just the "nicest" solution for me and my definition of "nice" – user1816847 Apr 09 '20 at 18:14
  • @user1816847 Use the setting i mentioned – rioV8 Apr 09 '20 at 21:52