I just installed python-mode from ELPA and when I hit Enter the cursor goes straight to the beginning of the next line. For instance for the following code:

我刚刚从ELPA安装了python-mode,当我按Enter键时,光标直接进入下一行的开头。例如,对于以下代码:

def hello_world():
    print "hello world!"
    for i in range(3):
        print "hello again"
    return 0

I have to hit TAB after Enter every time after I hit Enter to go to a new-line (although interestingly TAB sends the cursor to the right place).

每次按Enter键进入换行符后,我必须在Enter后点击TAB(尽管有趣的是TAB将光标发送到正确的位置)。

When I installed python-mode I got some warning messages relating to indentation which I don't really understand, here is a link to those warning messages.

当我安装了python-mode时,我得到了一些与缩进相关的警告消息,我并不理解,这里是这些警告消息的链接。

3 个解决方案

#1


4

C-j is the key I was looking for ('newline-and-indent' command). I managed to rebind Enter to this by putting the following hook in my init.el:

C-j是我正在寻找的关键('newline-and-indent'命令)。我设法通过在我的init.el中放入以下钩子来重新绑定Enter:

(add-hook 'python-mode-hook
          (lambda ()
             (define-key python-mode-map "\r" 'newline-and-indent)))

更多相关文章

  1. pylogin系列之V2EX自动领币消息提醒
  2. Linux下多任务间通信和同步-消息队列
  3. MYSQL存储过程,函数,光标
  4. 安卓消息处理机制
  5. JAVA实现 springMVC方式的微信接入、实现消息自动回复
  6. 为什么我们应该将XMPP而不是JSON用于简单(仅文本)消息传递应用程序
  7. SQLite的Android光标在方法调用时崩溃
  8. Android[中级教程] 深入剖析Android消息机制
  9. 更改Edittext光标的颜色与粗细

随机推荐

  1. 使用不同的条件,在同一个表的一个SQL查询
  2. 下标越界: '[number: 0]'
  3. 如何将MDB (Access)文件转换为MySQL(或纯
  4. phthon 连接sql server数据库执行存储过
  5. PostgreSQL+pgpooll+Keepalived双机HA方
  6. 如何以小时为单位从oracle数据库中获取数
  7. 关于SQL注入的一些问题...URL注入....
  8. 如何用sql语句查询出当月的每日数据量
  9. 关系代数(Relation Algebra)与SQL语句的对
  10. MySQL如何锁定一条记录?