我使用Vim編程進行編程,這裏是我面臨的問題。自動命令不能在Vim中工作,如何根據文件類型設置makeprg?
我使用多個選項卡同時編輯C++和Python文件,我已經加入我的.vimrc文件下面
filetype plugin indent on
au filetype python set mp=python3\ %
au filetype cpp set mp=g++\ -Werror\ -Wextra\ -Wall\ -ansi\ -pedantic-errors\ -g\ %
即所有我想要的是,當我切換到標籤與Python文件並運行:make
,它應該運行:!python3 %
,當我切換到標籤與C++文件並運行:make
它應該運行:!g++ -Werror -Wextra -Wall -ansi -pedantic-errors -g %
但是它不工作,每次我切換選項卡,並運行:make
,它試圖執行!g++ -Werror -Wextra -Wall -ansi -pedantic-errors -g %
和當我在2個文件(即Python和C++)上運行:set ft?
來檢查文件類型是否已被正確識別時,我得到正確的結果,即python和cpp。
那麼爲什麼這個自動命令不起作用?我錯過了什麼嗎? 感謝您的耐心等待
AFAIK makecmd沒有綁定到緩衝區,所以最後執行的命令獲勝。 – Rudi 2010-05-26 06:44:53
已解決 au BufRead,BufEnter,BufNewFile * .cpp,*。C set mp = g ++ \ -Werror \ -Wextra \ -Wall \ -ansi \ -pedantic-errors \ -g \%au BufRead,BufEnter,BufNewFile * .py,*。pyw set mp = python3 \% – ghayalcoder 2010-05-26 08:48:50