为什么我的 ftplugin 中的格式适用于所有格式的所有文件?
Why is the formatting in my ftplugin applying to all files in every format?
我为我的备忘单创建了自定义文件格式 .cheat
,在这种格式下,我只突出显示交替的行,以便于查看哪个击键组合触发了每个命令。为什么我的 ftplugin 中的格式适用于所有格式的所有文件?
来自~/.vim/vimrc
的关键行:
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
:
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
:
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
您的 ftdetect/cheat.vim
应仅包含以下内容:
au BufNewFile,BufRead *.cheat set filetype=cheat
而其余的配置你应该放在 ftplugin/cheat.vim
:
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
我为我的备忘单创建了自定义文件格式 .cheat
,在这种格式下,我只突出显示交替的行,以便于查看哪个击键组合触发了每个命令。为什么我的 ftplugin 中的格式适用于所有格式的所有文件?
来自~/.vim/vimrc
的关键行:
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
:
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
:
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
您的 ftdetect/cheat.vim
应仅包含以下内容:
au BufNewFile,BufRead *.cheat set filetype=cheat
而其余的配置你应该放在 ftplugin/cheat.vim
:
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