Disabling cells

Pluto allows you to disable a cell, which means that it will not get executed with reactivity. When one of the dependencies of a disabled cell changes, the disabled cell will not get executed as usual.

Disabled cells are indicated by a โ€˜greyed-outโ€™ appearance. Pressing the โ€œRunโ€ button (Shift-Enter) will not execute the cell, but it will save any changes to the cell code.

In this video, the disabled cell no longer responds to changes in the count variable. (The same applies when count is defined in code, instead of with a slider.)

Reactive

The cell disabling feature is reactive โ€“ย any cells that depend on a disabled cell will also be disabled. This ensures that the notebook remains consistent, and there is no code that executes with old values that no longer exist.

This is also a really powerful feature, because you can easily disable a large number of cells at once, by disabling a core cell that is used in all of them.

In this video, the last cell is disabled indirectly, because it depends on the disabled cell through the text variable.

Other uses

Disabling a cell can also be useful for other purposes, such as:

  • Dramatic effect: You can use this when showing a piece of code, but you donโ€™t want to show the result yet.

Disabling in file

There is also the option to disable a cell in the file. This makes no difference when running the notebook in Pluto, but the cell code will be stored as a Julia comment in the file.

This is useful when you are writing a Pluto notebook file (.jl) that is also used as a Julia script. This lets you write code that is only executed when the notebook is used in Pluto, such as additional plots, testing, or more.

A screenshot of a Pluto notebook file with a disabled cell.

Notice the gray markers to the right of the cells, marking a cell disabled in file (second cell) and a cell disabled indirectly in file (last cell).

File format

Before the cell is disabled in file, the .jl notebook file looks like:

# โ•”โ•โ•ก d5697b7b-a916-468c-9a2a-e84a87d7320f
@bind count Slider(5:20)

# โ•”โ•โ•ก 6a653410-c595-45fb-8357-6ffe815e9d49
text = repeat("๐ŸŽˆ", count)

# โ•”โ•โ•ก 94216444-bcfb-4925-bc16-44b698181286
sum(codeunits(text))

After disabling the second cell in file, you get:

# โ•”โ•โ•ก d5697b7b-a916-468c-9a2a-e84a87d7320f
@bind count Slider(5:20)

# โ•”โ•โ•ก 6a653410-c595-45fb-8357-6ffe815e9d49
# โ• โ•โ•ก skip_as_script = true
#=โ• โ•โ•ก
text = repeat("๐ŸŽˆ", count)
  โ• โ•โ•ก =#

# โ•”โ•โ•ก 94216444-bcfb-4925-bc16-44b698181286
#=โ• โ•โ•ก
sum(codeunits(text))
  โ• โ•โ•ก =#

Reactive

The Disable in File feature is reactive, just like the โ€œDisableโ€ feature. This means that any cells that depend on a cell that is disabled in file will also be disabled in file. The reasons here are similar: it makes sense for consistency, and it makes it easy to disable a large number of cells at once.