[英]How to send status to the VIM status line after calling custom VIM (Python) function
[英]Autocmd in vim not calling the function
" Python logger-print and vice-versa
function! SetPrintLogMaps()
echom "called"
nnoremap <buffer> <Leader>lp "lyy"lp"l5cawprint^[
nnoremap <buffer> <Leader>ll "lyy"lp"lcawself.logger.info(^O$)^[
endfunction
autocmd BufWrite,BufRead *.py :call SetPrintLogMaps()
我有這個autocmd,以便僅在讀取或寫入python腳本時設置映射。 但是當我打開任何python腳本時都不會調用該函數。
我剛剛發現,如果我從命令行打開像vim test.py
這樣的腳本,它將無法正常工作。 但是,如果我只是打開vim
然后執行:e test.py
該函數被調用。
您應該使用FileType
事件:
augroup myPythonStuff
autocmd!
autocmd FileType python call SetPrintLogMaps()
augroup END
最好將它放在~/.vim/after/ftplugin/python.vim
:
nnoremap <buffer> <leader>lp "lyy"lp"l5cawprint^[
nnoremap <buffer> <leader>ll "lyy"lp"lcawself.logger.info(^O$)^[
並稱之為一天。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.