Standard python interpreter has a vi command mode?

前端 未结 4 1315
天命终不由人
天命终不由人 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条回答
  •  醉梦人生
    2020-12-23 10:32

    This kind of all depends on a few things.

    First of all, the python shell uses readline, and as such, your ~/.inputrc is important here. That's the same with psql the PostgreSQL command-line interpreter and mysql the MySQL shell. All of those can be configured to use vi-style command bindings, with history etc.

    will put you into vi mode at the python shell once you've got your editing mode set to vi

    You may need the following definition in your ~/.inputrc

    set editing-mode vi
    

    OSX info

    OSX uses libedit which uses ~/.editrc. You can man editrc for more information.

    For example, to mimick a popular key combination which searches in your history, you can add the following to your .editrc

    bind "^R" em-inc-search-prev
    

提交回复
热议问题