Emacs是最好的Python编辑器之一。Emacs还可以煮咖啡[1]-_-||
Emacs的python mode能够让编辑Python脚本变得非常得舒服。我们来围观一下Emacs自带的Python mode里面的快捷键:
执行Python代码
C-c RET
imports or reloads the file in the Python interpreterC-c C-c
把整个buffer的内容发送到python解释器,就相当于运行这个文件。C-c |
把当前选取发送过去C-M-x
发送当前函数定义或者类定义C-c C-s
发送任意字符串过去,也就是执行任意Python命令C-c !
starts a Python interpreter window; this will be used by subsequent Python execution commands
缩进
C-c <tab>
根据上下文重新缩进选区C-c <
左移选区C-c >
右移
选择
M-x py-mark-block
选中一个blockC-M-h
选中函数C-u C-M-h
选中类
移动
C-M-a
移动到函数定义defC-u C-M-a
移动到类定义C-M-e
移动到函数定义结束C-u C-M-e
类定义结束
Misc
C-c ?
打开python-mode的文档