태그 보관물: highlighting

highlighting

Vim에서 특정 파일 형식에 대해서만 로컬 일치를 설정하는 방법은 무엇입니까? 나는 로컬 구성으로 설정할 수 있습니다

에서 나는 로컬 구성으로 설정할 수 있습니다 :

 setlocal number

특정 파일 형식에 대해서만 로컬 일치를 설정하려면 어떻게해야합니까?

나는 이것을 사용한다 :

 autocmd! BufEnter *.py,.vimrc,*.sh,*.c* :match ColorColumn /\%>80v.\+/

그러나 동일한 세션에서 다른 파일 형식의 파일을 열면 일치 ColorColumn합니다.



답변

이것은 더 이상 저자에게는 유용하지 않을 수 있지만 다음을 넣습니다 .vim/ftplugin/python.vim.

if exists('+colorcolumn')
    setlocal colorcolumn=81
else
    au! BufEnter <buffer> match ColorColumn /\%81v.*/
endif

ftplugin에 있기 때문에 python 파일에서만 발생하며 BufEnter는 python 파일이있는 버퍼에 로컬로 유지합니다.


답변

나는 이것을 해결했다.

augroup longLines
    autocmd! BufEnter *.py,.vimrc,*.sh,*.c* :match ColorColumn /\%>80v.\+/
augroup END


답변

파이썬 이나 C 파일 형식이 열려 있을 때 강조 표시가 활성화됩니다 (다른 파일을 자유롭게 추가하십시오. 어떤 파일 형식 * .sh 확장자가 속하는지 몰랐습니다).

augroup LongLines
    autocmd!
    autocmd FileType * match none
    autocmd FileType python,c,sh match ColorColumn /\%>80v.\+/
augroup END


답변