[英]vim filetype settings lost when resourcing vimrc
Following the instructions here I have an ftdetect file, ~/.vim/ftdetect/cheat.vim
with this line: 按照这里的说明,我有一个ftdetect文件,
~/.vim/ftdetect/cheat.vim
与此行:
au BufNewFile,BufRead *.cheat/* set filetype=cheat
This loads a simple config file at ~/.vim/ftplugin/cheat.vim
: 这会在
~/.vim/ftplugin/cheat.vim
加载一个简单的配置文件:
set statusline=%t
set statusline+=\ %P
set statusline+=%#todo#
set nonumber
It loads fine, but when I source ~/.vimrc
the settings for cheat.vim
are lost. 它加载正常,但是当我获取
~/.vimrc
, cheat.vim
的设置丢失了。
The best long-term solution is to avoid having your vimrc overwrite filetype settings if executed directly by using local options and similar, but the simplest fix is often to re-edit the file. 最好的长期解决方案是,避免使用本地选项等直接执行vimrc来覆盖文件类型设置,但是最简单的解决方法通常是重新编辑文件。 Type
类型
:edit
And hit Enter. 然后按Enter。
This can be shortened to just :e
in interactive use, and a mapping is easily created: 在交互使用中,可以将其简化为
:e
,并且可以轻松创建映射:
nnoremap <silent> <leader>e :edit<CR>
I suggest reading the help pages on vim's startup, init files, source command, edit command, and the various ways to tune things local to a single buffer (eg, setlocal
, map-<buffer>
, autocmd pattern <buffer>
). 我建议阅读有关vim的启动,初始化文件,源命令,编辑命令以及各种方法的帮助页面,这些方法可以调整单个缓冲区的本地内容(例如
setlocal
, map-<buffer>
,autocmd pattern <buffer>
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.