Skip to content

Instantly share code, notes, and snippets.

@tkanmae
Last active December 22, 2015 12:19
Show Gist options
  • Save tkanmae/6471899 to your computer and use it in GitHub Desktop.
Save tkanmae/6471899 to your computer and use it in GitHub Desktop.
Custom IPython Notebook style.
div#notebook-container {
width: 105ex;
}
div.cell {
margin-left: auto;
margin-right: auto;
}
div.text_cell_render {
font-family: "Charis SIL", "STIX", serif;
font-size: 120%;
line-height: 145%;
}
.rendered_html code {
font-size: 81.3%;
}
.rendered_html h1 {
text-align: center;
}
.rendered_html h2 {
}
.rendered_html li {
margin-top: 0.25em;
}
.rendered_html table {
margin-left: auto;
margin-right: auto;
}
.CodeMirror {
font-family: "Source Code Pro", "Inconsolata", monospace;
}
"use strict";
// Use Vim key bindings.
$.getScript("/static/components/codemirror/keymap/vim.js", function() {
if (IPython.Cell) {
IPython.Cell.options_default.cm_config.keyMap = "vim";
}
});
// Enable line wrapping in CodeCell.
if (IPython.CodeCell) {
IPython.CodeCell.options_default.cm_config.lineWrapping = true;
}
$([IPython.events]).on('app_initialized.NotebookApp', function() {
if (window.marked) {
window.marked.setOptions({smartypants: true});
}
// Handle <ESC> in the way Vim handles it.
IPython.keyboard_manager.edit_shortcuts.add_shortcut('esc', function(event) {
var cm = IPython.notebook.get_selected_cell().code_mirror;
if (cm.state.vim) {
if (cm.state.vim.insertMode) {
CodeMirror.keyMap['vim-insert']['Esc'](cm);
return false;
}
}
IPython.notebook.command_mode();
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment