vim syntax highlighting and indentation
过去多啦不再A梦
过去多啦不再A梦 2017-05-16 16:41:27
0
2
835

Recently, I need to use vim to edit a text file with the .cl suffix, but vim always automatically highlights the .cl file in the .lisp syntax. To disable file highlighting, add the following statement to .vimrc:

autocmd BufNewFile,BufRead *.cl set filetype=

This successfully cancels syntax highlighting. But at the same time, I found that the .cl file still maintains the automatic indentation habit of lisp files. I want its indentation habits to maintain those of java or python, so I changed them to

autocmd BufNewFile,BufRead *.cl set filetype=python

But without success. My .vim file already has set autoindent set. How should I solve it?

过去多啦不再A梦
过去多啦不再A梦

reply all(2)
仅有的幸福

I accidentally saw a post today, and it said that nolisp is available. Then I tried it myself and it worked. I think it may be that vim automatically recognizes the *.cl file as a lisp file and then sets lisp. As long as you cancel the setting, the indentation of the new line will be the same as the previous line. In addition, I found that the filetype does not need to be set to Python. I just need indentation similar to Python and do not need syntax highlighting. Attached is my .vimrc related settings:

set autoindent
autocmd BufNewFile,BufRead *.cl set filetype=
autocmd BufNewFile,BufRead *.cl set nolisp
刘奇

You can refer to the content in the link below. The reason is probably because you have set up the BufNewFile,而*.clfile
Already existed before.

BufNewFile starts editing a file that does not exist yet

Reference:
1. http://vimcdoc.sourceforge.net/doc/autocmd.html#autocmd-events

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template