用vim和ipython命令行远程调试python代码,但是两个窗口切来切去总不是很方便,希望能定制化ipython,并能在里面直接调试
首先创建ipython的设置文件
ipython profile create
cd ~/.ipython/profile_default
vi ~/.ipython/profile_default/ipython_config.py
这个文件就是设置文件
添加了这些内容(这几行注释去掉了)
c.InteractiveShellApp.exec_lines = ['import pandas as pd', 'pd.set_option("display.max_columns",None)', 'pd.set_option("display.max_rows",None)']
c.TerminalIPythonApp.force_interact = True
c.InteractiveShell.autocall = 1
import sys
import IPython
c.InteractiveShell.banner1 = \
' Python\t: ' + sys.version.replace('\n', ' ') + '\n' + \
' IPython\t: ' + IPython.__version__ + '\n' \
' Interpreter\t: ' + sys.executable + '\n'
c.TerminalInteractiveShell.editing_mode = 'vi'
c.TerminalInteractiveShell.editor = 'vi'
c.TerminalInteractiveShell.extra_open_editor_shortcuts = True
c.TerminalInteractiveShell.prompt_includes_vi_mode = True
c.Completer.backslash_combining_completions = True
c.Completer.greedy = True
c.Completer.jedi_compute_type_timeout = 400
c.Completer.use_jedi = True
实现的功能:
- 自动导入pandas
- 用
!vim
可以使用系统的vim查看文档,同理如果使用系统命令就在前面加!(英文感叹号) %run xx.py
可以在console中运行脚本,调试很方便