I'm created a custom file format, .cheat
, for my cheat sheets, and in that format only I am highlighting alternating rows to make it easy to see which keystroke combo triggers each command. Why is the formatting in my ftplugin applying to all files in every format?
Key lines from ~/.vim/vimrc
:
set nocompatible
au BufNewFile,BufRead *.cheat set filetype=cheat
filetype off
" vundle stuff
filetype on
nmap <leader>? :75vsp ~/.vim/my.cheat
(Full vimrc
below for reference.)
Full ~/.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
Full ~/.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
Your ftdetect/cheat.vim
should only contain the following :
au BufNewFile,BufRead *.cheat set filetype=cheat
While the remaining configurations you should place in a 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