diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js
index 71eb219..e7506c9 100644
--- a/IPython/frontend/html/notebook/static/js/codecell.js
+++ b/IPython/frontend/html/notebook/static/js/codecell.js
@@ -48,9 +48,10 @@ var IPython = (function (IPython) {
CodeCell.prototype.handle_codemirror_keyevent = function (editor, event) {
- // This method gets called in CodeMirror's onKeyDown/onKeyPress handlers and
- // is used to provide custom key handling. Its return value is used to determine
- // if CodeMirror should ignore the event: true = ignore, false = don't ignore.
+ // This method gets called in CodeMirror's onKeyDown/onKeyPress
+ // handlers and is used to provide custom key handling. Its return
+ // value is used to determine if CodeMirror should ignore the event:
+ // true = ignore, false = don't ignore.
if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
// Always ignore shift-enter in CodeMirror as we handle it.
return true;
@@ -59,8 +60,8 @@ var IPython = (function (IPython) {
var cur = editor.getCursor();
var pre_cursor = editor.getRange({line:cur.line,ch:0},cur).trim();
if (pre_cursor === "") {
- // Don't autocomplete if the part of the line before the cursor is empty.
- // In this case, let CodeMirror handle indentation.
+ // Don't autocomplete if the part of the line before the cursor
+ // is empty. In this case, let CodeMirror handle indentation.
return false;
} else {
// Autocomplete the current line.
@@ -86,9 +87,19 @@ var IPython = (function (IPython) {
} else {
return false;
};
- } else {
- // keypress/keyup also trigger on TAB press, and we don't want to use those
- // to disable tab completion.
+ } else if (event.keyCode === 76 && event.ctrlKey && event.shiftKey
+ && event.type == 'keydown') {
+ // toggle line numbers with Ctrl-Shift-L
+ if (this.code_mirror.getOption('lineNumbers') == false) {
+ this.code_mirror.setOption('lineNumbers', true);
+ } else {
+ this.code_mirror.setOption('lineNumbers', false);
+ }
+ this.code_mirror.refresh()
+ }
+ else {
+ // keypress/keyup also trigger on TAB press, and we don't want to
+ // use those to disable tab completion.
if (this.is_completing && event.keyCode !== 9) {
var ed_cur = editor.getCursor();
var cc_cur = this.completion_cursor;
@@ -470,4 +481,3 @@ var IPython = (function (IPython) {
return IPython;
}(IPython));
-
diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js
index f5fcdc8..084e8f8 100644
--- a/IPython/frontend/html/notebook/static/js/notebook.js
+++ b/IPython/frontend/html/notebook/static/js/notebook.js
@@ -186,6 +186,7 @@ var IPython = (function (IPython) {
var shortcuts = [
{key: 'Shift-Enter', help: 'run cell'},
{key: 'Ctrl-Enter', help: 'run cell in terminal mode'},
+ {key: 'Ctrl-Shift-L', help: 'toggle line numbering'},
{key: 'Ctrl-m d', help: 'delete cell'},
{key: 'Ctrl-m a', help: 'insert cell above'},
{key: 'Ctrl-m b', help: 'insert cell below'},