24
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IPython notebookでemacs or vimのキーバインドを使う

Last updated at Posted at 2014-08-11

皆さん、超便利なipython notebook使ってますよね。
そして、vimやemacsユーザーの皆さんは、vimのキーバインドやemacsのキーバインドが使えなくて苦しんでますよね?


そんなあなたに魔法のjsコードをプレゼントしましょう。


以下のjsを、$IPYTHONDIR/profile_default/static/custom/custom.jsの末尾に追記しましょう。

魔法のコード
var my_keymap = 'emacs';
// var my_keymap = 'vim';

$.getScript("/static/components/codemirror/keymap/" + my_keymap + ".js");

IPython.RawCell.options_default.cm_config = {keyMap: my_keymap};
IPython.Cell.options_default.cm_config.keyMap = my_keymap;
IPython.TextCell.options_default.cm_config.keyMap = my_keymap;
IPython.MarkdownCell.options_default.cm_config.keyMap = my_keymap;
IPython.HeadingCell.options_default.cm_config = {keyMap: my_keymap};
IPython.CodeCell.options_default.cm_config.keyMap = my_keymap;

環境変数IPYTHONDIRが存在しない場合は、ipythonを起動して、以下のコードで確認できます。(典型的には$HOME/.ipython, $HOME/.config/ipythonが多いみたいです。詳しくはここ。)

import IPython
IPython.utils.path.get_ipython_dir()

ちなみに確認環境はipython2.1.0.

24
26
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?