如果完整文件名不包含模式,请运行自动命令(Run autocommand if full file name does not include pattern)
每次我保存一个python文件时,我都有一个运行flake8的函数。 但是,如果完整文件名(完整路径)包含/.git/ ,我不希望该函数运行。 我怎样才能做到这一点? 我尝试了以下但未成功:
au BufWritePost */[^git]/*.py call s:MyFlake8()I have a function to run flake8 every time I save a python file. However I don't want that function to run if the full file name (full path) includes /.git/. How can I achieve that? I tried the following without success:
au BufWritePost */[^git]/*.py call s:MyFlake8()最满意答案
如果条件不符合,我会在MyFlake8顶部进行提前检查并退出。
function! MyFlake8() if expand("%:p") =~ "/\\.git/" return endif echo "FLAKE8!" endfunction au BufWritePost *.py call s:MyFlake8()I'd do an early check at top of MyFlake8 and exit if conditions are not met.
function! MyFlake8() if expand("%:p") =~ "/\\.git/" return endif echo "FLAKE8!" endfunction au BufWritePost *.py call s:MyFlake8()更多推荐
发布评论