How can I select matching keywords in a Jupyter notebook via a keyboard shortcut? For example, in the Atom/Sublime editor I can hit cmd + D
on a mac (or Ctrl + d
on Windows) while the cursor is over 'var' and each time I do that the next 'var' will be highlighted. I can then type the new variable name and 'var' is replaced with whatever I typed.
var = "hello" print(var) print(var)
Is there an equivalent in a Jupyter notebook?
How can I select matching keywords in a Jupyter notebook via a keyboard shortcut? For example, in the Atom/Sublime editor I can hit cmd + D on a mac (or Ctrl + d on Windows) while the cursor is over 'var' and each time I do that the next 'var' will be highlighted.
Capturing Output With %%capture IPython has a cell magic, %%capture , which captures the stdout/stderr of a cell. With this magic you can discard these streams or store them in a variable. By default, %%capture discards these streams. This is a simple way to suppress unwanted output.
Add custom.js
to
C:\Users\username\.jupyter\custom # for Windows and ~/.jupyter/custom/ # for Mac
with content
require(["codemirror/keymap/sublime", "notebook/js/cell", "base/js/namespace"], function(sublime_keymap, cell, IPython) { cell.Cell.options_default.cm_config.keyMap = 'sublime'; cell.Cell.options_default.cm_config.extraKeys["Ctrl-Enter"] = function(cm) {} var cells = IPython.notebook.get_cells(); for(var cl=0; cl< cells.length ; cl++){ cells[cl].code_mirror.setOption('keyMap', 'sublime'); cells[cl].code_mirror.setOption("extraKeys", { "Ctrl-Enter": function(cm) {} }); } } );
and restart jupyter. Now Ctrl+D
should work like it does in Sublime
.
You can see that Ctrl-Enter
functionality is disabled as it would be very convenient to run current cell rather than creating new line for most users. You can choose to have that functionality by commenting that line out.
You can disable other key config that you don't want in a similar way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With