Vim 为什么下面的函数设置filetype=conf?
我的Vim 为什么下面的函数设置filetype=conf?,vim,Vim,我的.vimrc中有以下功能: autocmd Filetype mkd call SetWritingOptions() function SetWritingOptions() colorscheme pencil setlocal background=light setlocal guifont=Cousine\ 11 setlocal spell! spelllang=en_us setlocal noexpandtab setlocal textwidth=
.vimrc
中有以下功能:
autocmd Filetype mkd call SetWritingOptions()
function SetWritingOptions()
colorscheme pencil
setlocal background=light
setlocal guifont=Cousine\ 11
setlocal spell! spelllang=en_us
setlocal noexpandtab
setlocal textwidth=52
setlocal linespace=4
setlocal noruler
setlocal nonumber
setlocal wrap
setlocal linebreak
setlocal nolist
setlocal display+=lastline
execute "Goyo"
endfunction
(Goyo是Vim的无分发模式插件:)
我添加这个是为了处理标记
文件
现在一切都正常了,除了我最后得到了filetype=conf
,如果我删除execute“Goyo”
为什么会这样?如何修改该函数,使其以filetype=mkd
结尾
(我尝试在末尾添加
filetype=mkd
,但Vim一直在调用该函数,直到它中断为止) Goyo命令在一个由4个不可见的填充窗口包围的新选项卡中的新窗口中打开当前文档。窗口本地设置(setlocal
)将不会应用于此新Goyo窗口
因此,实现这一点的正确方法是使用,使用它可以指定创建新Goyo窗口和关闭窗口时调用的两个函数
请注意,示例中的大多数设置都是全局设置,无法在本地应用,因此您可能希望在第二个回调函数中恢复这些设置
function! SetWritingOptions()
colorscheme pencil
setlocal background=light
setlocal guifont=Cousine\ 11
setlocal spell! spelllang=en_us
setlocal noexpandtab
setlocal textwidth=52
setlocal linespace=4
setlocal noruler
setlocal nonumber
setlocal wrap
setlocal linebreak
setlocal nolist
setlocal display+=lastline
endfunction
function! UnsetWritingOptions()
" Fill in!
" Revert global options
endfunction
let g:goyo_callbacks = [function('SetWritingOptions'), function('UnsetWritingOptions')]
augroup GoyoMarkdown
autocmd!
autocmd FileType mkd nested if !has('vim_starting')|execute 'Goyo'|endif
autocmd VimEnter *.md,*.mkd,*.markdown nested Goyo
augroup END
为什么让行
执行“Goyo”
而不是只执行Goyo
?你从:verbose set ft?
,:Goyo
,:verbose set ft?
中得到了什么?