How do I use vi keys in ipython under *nix?

前端 未结 6 1332
闹比i
闹比i 2020-12-04 07:48

Currently in Bash I use set -o vi to enable vi mode in my bash prompt.

How do I get this going in ipython?

Note: If an answer applies t

6条回答
  •  没有蜡笔的小新
    2020-12-04 08:05

    You may set vi in your .ipython start-up config file. Create one if you don't have it by adding a file to ~/.ipython/profile_default/startup/ called something like start.py. Here's an example:

    # Initializing script for ipython in ~/.ipython/profile_default/startup/
    from IPython import get_ipython
    ipython = get_ipython()
    
    # If in ipython, set vi and load autoreload extension
    if 'ipython' in globals():
        ipython.editing_mode = 'vi'
        ipython.magic('load_ext autoreload')
        ipython.magic('autoreload 2')
    from Myapp.models import * 
    

    That last line is if you use ipython with Django, and want to import all your models by default.

提交回复
热议问题