开发者

Is it possible to disable the LargeFile Vim plugin for certain filetypes?

I am mostly happy with the LargeFile plugin, but have recently had a need to selectively disable it for a specific filetype. The LargeFile plugin disables the FileType event; and the filetype in question is determined from the file contents, not the file extension, so I need to use the 开发者_Go百科BufReadPost event like so:

au BufReadPost * if &ft == "myfiletype" | let g:LargeFile=100 | endif

But setting g:LargeFile has no effect there. I also tried calling the :Unlarge command with no effect. How can I disable the LargeFile plugin or modify its settings based on the filetype?


Your auto-command does not work because at the moment of its execution the filetype of the current buffer is not detected yet. If the target filetype can be deduced from the filename, use an auto-command pattern instead of testing against the filetype.

Here is an example for C files:

autocmd BufRead *.c Unlarge

If the filename pattern detection is not sufficient, manually trigger the filetype detection first:

autocmd BufRead *.c
\   if !did_filetype() | filetype detect | endif |
\   if &ft is# 'c' | Unlarge | endif
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜