簡體   English   中英

我運行python文件后在bash中運行的Vim命令

[英]Vim commands running in bash after I run a python file

運行python單元測試文件后出現問題。 一旦文件退出,我只能在按“ i”並使用其他vim鍵盤綁定后與控制台進行交互。 我還注意到,使用箭頭鍵遍歷輸入的內容將在行尾刪除隨機數的字符。

EX:

$ ./tests.py -v
<output>
$ <cannot type>
<press "i">
$ I can now type
<press <- >
$ I can no

我正在使用RHEL 7和bash。 我已經嘗試使用Google搜索該問題,但是我對問題的格式設置不佳,或者是一個不常見的問題。

感謝您的幫助。

編輯:

實際的test.py包含私有代碼,但這是包含相同基本代碼的示例。

test.py

#!/usr/bin/env python

import unittest

class TestUtil(unittest.TestCase):
    def test_hello_world(self):
        text = "Hello World!"
        self.assertEqual("Hello World!", text)
        print(text)
        pass
if __name__ == '__main__':
    unittest.main()

聽起來好像您的外殼已進入vi-mode 這是一個readline的模式,你可以用vi編輯鍵而不是更常用的Emacs鍵。

我知道有兩種可能會發生這種情況。

set -o vi

bindkey -v

從技術上講,要關閉它,請使用set +o vi 但是,這將禁用所有內聯編輯。 您更可能希望返回emacs模式,這通常是默認模式。 為此,請執行以下操作:

set -o emacs

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM