2
我有一個vim文件中的以下代碼,它在編輯php文件時自動獲取。但我無法讓它工作。VIM:使用自定義函數作爲shell的參數
"PHP config
if !exists("g:addPath")
let g:addPath = 1
let $PATH=$PATH.';C:\Program Files\Mozilla Firefox'
endif
function! MakeThisUrl()
let s:url='http://localhost/'
let s:url=s:url. expand('%')
return s:url
endfunction
function! MakeCustomUrl()
let s:url='http://localhost/'
let s:url=s:url. expand('%:p')
return s:url
endfunction
map <F9> :w<CR>:!firefox -new-tab MakeThisUrl()<CR>
map <F10> :!firefox -new-tab call MakeCustomUrl()
imap <F9> <Esc>:w<CR>:!firefox -new-tab MakeThisUrl()<CR><CR>
imap <F10> <Esc>:!firefox -new-tab call MakeCustomUrl()
這個想法是讓vim自動生成正確的URL,所以我可以通過設置F9來測試代碼。但是,我不能讓它執行MakeThisUrl()和我得到它的
:!firefox -new-tab MakeThisUrl() <CR><CR>
代替
:!firefox -new-tab http://localhost/filename.php <CR><CR>
如何使它工作的任何想法? 在此先感謝
非常感謝,它工作得很好。沒有使用execute來生成命令。感謝'更新'提示,我將它應用於其他'au'上的文件 – masterLoki 2010-09-21 23:12:41