Standard python interpreter has a vi command mode?

前端 未结 4 1338
天命终不由人
天命终不由人 2020-12-23 10:12

I was working a bit in the python interpreter (python 2.4 on RHEL 5.3), and suddenly found myself in what seems to be a \'vi command mode\'. That is, I can edit previous com

4条回答
  •  -上瘾入骨i
    2020-12-23 10:52

    Use readline.parse_and_bind method. For example, try on python interactive console:

    import readline
    readline.parse_and_bind("set editing-mode vi")
    

    It seems any command you can set in .inputrc you can set via this method too. I tried it in Python 2.7 and 3.5.1.

    See also man readline


    EDIT (Dec 21th, 2019): or maybe, to have a true vim you can manage to patch the python's readline with Athame. I did it with bash and it is very cool.

提交回复
热议问题