2017-11-11 11 views
0

vimscript에 익숙하지 않으며 익숙하지 않습니다. 이것을 내 구성에 설치하고 싶습니다. https://github.com/vim-scripts/Twee-Integration-for-Vim이 파일을 내 .vim 디렉토리에 직접 넣습니다.Vimscript : 파일 유형이로드되지 않습니다.

이 파일에는 ~/.vim/ftdetect/twee.vim 파일이 있으며 일부 수정했습니다. 다음과 같이 표시됩니다.

" markdown filetype file 
if exists("did\_load\_filetypes") 
     echom "I put this here" 
     finish 
endif 

augroup twee 
     au! BufRead,BufNewFile *.twee,*.tw setfiletype twee 
     autocmd BufRead,BufNewFile *.twee,*.tw compiler twee 
augroup END 

직접 추가했습니다. 확장자가 .twee 인 파일을 열 때마다 그 echom을 출력합니다. 그러나 파일을 열 때 :set filetype?을 입력하면 다음과 같이 인쇄됩니다. filetype=

내가 뭘 잘못하고 있니? 이 자동 그룹을 실행하려면 어떻게해야합니까? 로컬 버퍼에서 :set filetype=twee하면 BTW, 구문 강조 표시가 제대로 작동합니다.

답변

0

대답은 여기에 있었다 : http://vim.1045645.n5.nabble.com/FTDetect-td1151042.html

There are a number of different methods of doing filetype detection; 
you have confused two of them. 

I don't understand exactly how the ftdetect directory works, but 
":help ftdetect" says that if you are going to add filetype 
detection for a new file type by putting a file in the ftdetect 
directory, that file should contain _only_ the autocommand, e.g., 

    au BufRead,BufNewFile *.wibble set filetype wibblewobble 

Note that there is no '!' after the 'au' and the command is "set 
filetype", not "setfiletype". Note also that the help entry does 
say, 

    Note that there is no "augroup" command, this has already been 
    done when sourcing your file. 

If, on the other hand, you add filetype detection by creating your 
own ~/.vim/filetype.vim file, _then_ you would put in that file the 
commands you used above, i.e., 

    if exists("did_load_filetypes") 
     finish 
    endif 
    augroup filetypedetect 
     au! BufRead,BufNewFile *.wibble setfiletype wibblewobble 
    augroup END