Sublime multiline select in Jupyter Notebook

Image credit: Unsplash

Jupyter Notebooks are incredible to work with interactive images and also for saving the result rendered. However, the absence of an equivalent to Ctrl+D would be very annoying for any Sublime Text user.

So, what can be done to overcome that?

The solution which was posted in a slew of GitHub issues123 and blog posts4, is as follows:

Step 1

Create a custom/ folder inside the .jupyter/ folder that is located at /home/<user>.

The position of the folder is as follows:

home
|-<user>/
|--.jupyter/
|---custom/

Step 2

Create a file named custom.js and add the following code.

require(["codemirror/keymap/sublime", "notebook/js/cell", "base/js/namespace"],

	function(sublime_keymap, cell, IPython) {
		cell.Cell.options_default.cm_config.keyMap = 'sublime';
		var cells = IPython.notebook.get_cells();
		for(var c=0; c< cells.length ; c++){
			cells[c].code_mirror.setOption('keyMap', 'sublime');
		}
	}
);

Step 3

Kill all existing Jupter Notebook sessions and restart Jupter Notebook.


Now using Ctrl+D should enable multi-line selection. 🎉

References