首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的ftplugin中的格式适用于所有格式的文件?

为什么我的ftplugin中的格式适用于所有格式的文件?
EN

Stack Overflow用户
提问于 2017-04-03 06:48:02
回答 1查看 146关注 0票数 0

我为备忘单创建了一个自定义文件格式.cheat,在这种格式中,我只突出显示交替行,以便于查看哪个击键组合触发了每个命令。为什么我的ftplugin中的格式适用于所有格式的文件?

来自~/.vim/vimrc的关键行

代码语言:javascript
复制
set nocompatible                                                                                                        
au BufNewFile,BufRead *.cheat set filetype=cheat
filetype off 
" vundle stuff
filetype on
nmap <leader>? :75vsp ~/.vim/my.cheat

(下面是完整的vimrc,供参考。)

~/.vim/ftdetect/cheat.vim

代码语言:javascript
复制
if exists("b:did_load_filetypes") | finish | endif                                                                      
let b:did_ftplugin = 1                                       
au BufNewFile,BufRead *.cheat set filetype=cheat

syn match Oddlines "^.*$" contains=ALL nextgroup=Evenlines skipnl  
syn match Evenlines "^.*$" contains=ALL nextgroup=Oddlines skipnl
hi Oddlines ctermbg=DarkGray ctermfg=White
hi Evenlines ctermbg=LightGray ctermfg=White

~/.vim/vimrc

代码语言:javascript
复制
set nocompatible
au BufNewFile,BufRead *.cheat set filetype=cheat                                                                                                
filetype off 
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
  Plugin 'VundleVim/Vundle.vim'
  Plugin 'dracula/vim'
  Plugin 'vim-airline/vim-airline'
  Plugin 'tpope/vim-commentary'
  Plugin 'neilagabriel/vim-geeknote'
  Plugin 'tpope/vim-fugitive'
  Plugin 'moll/vim-node'
  Plugin 'danro/rename.vim'
  Plugin 'vim-syntastic/syntastic'
  set statusline+=%#warningmsg#
  set statusline+=%{SyntasticStatuslineFlag()}
  set statusline+=%*
  let g:syntastic_always_populate_loc_list=1
  let g:syntastic_auto_loc_list=1
  let g:syntastic_check_on_open=1
  let g:syntastic_check_on_wq=0
call vundle#end() 
filetype plugin indent on 
set number
set wrap
set breakindent
set autoindent
set shiftwidth=2
set linebreak
set nolist
set cursorline
set cursorcolumn
set ruler
set laststatus=2
set timeoutlen=1000 ttimeoutlen=0
set splitright
hi CursorLine  cterm=NONE ctermbg=Black ctermfg=None
hi CursorColumn cterm=NONE ctermbg=Black ctermfg=None
set updatetime=200
au CursorHold * silent! update
nmap <CR> o<Esc>
nmap <leader>? :75vsp ~/.vim/my.cheat
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-03 06:53:13

您的ftdetect/cheat.vim应该只包含以下内容:

代码语言:javascript
复制
au BufNewFile,BufRead *.cheat set filetype=cheat

而其余的配置则应该放在ftplugin/cheat.vim中:

代码语言:javascript
复制
if exists("b:did_ftplugin") | finish | endif
let b:did_ftplugin = 1

syn match Oddlines "^.$" contains=ALL nextgroup=Evenlines skipnl
syn match Evenlines "^.$" contains=ALL nextgroup=Oddlines skipnl
hi Oddlines ctermbg=DarkGray ctermfg=White
hi Evenlines ctermbg=LightGray ctermfg=White
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43178144

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档