Home  >  Q&A  >  body text

vim syntax highlighting and indentation

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梦2712 days ago795

reply all(2)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-16 16:43:27

    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
    

    reply
    0
  • 怪我咯

    怪我咯2017-05-16 16:43:27

    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

    reply
    0
  • Cancelreply