[英]“Error: unknown shorthand flag: 'f' in -f5” when running bash script from Python
[英]Vim — running external command bound to F5 to run Python script results in error
我將以下內容添加到我的.vimrc文件中:
nnoremap <silent> <F5>!python %
當我按下F5時,這應該在Python中運行當前文件。 相反,它會給出以下錯誤:
Trackback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 349, in f_with_update
File "<string>", line 358, in run_this file
NameError: global name 'send' is not defined
Press Enter or type command to continue
如果我每次運行VIM時手動重新映射F5,則此命令有效:
:map <silent> <F5>!python %
我不記得將任何內容映射到F5,我的.vimrc文件不包含任何映射器。 知道發生了什么事嗎?
nnoremap <silent> <F5>!python %
將<F5>!python
映射到%
。 你想要的是這個:
nnoremap <silent> <F5> :!python %<CR>
法線貼圖需要:
如果要使用普通的cmd-line命令,則需要使用<CR>
結束它以執行命令。 將右側的所有內容都視為您自己鍵入的鍵。
你可能會發現python上的這個vim wiki頁面很有用。
<F5>
可能映射到別處。 嘗試:verbose nmap <F5>
以查看位置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.