简体   繁体   中英

How to remove custom vim syntax and filetype settings for a specific

I somehow botched the default syntax highlighting and filetype recognition for my apache httpd-vhosts.conf file, such that every time I open it in vim, the syntax and filetype are both set to "conf". All of the other files in the ../conf.d/ directory are recognized properly, ie as syntax and filetype both set to "apache". I've tried the following:

  1. manually setting both in vim, ie

    • :set syntax=apache, :set filteype=apache
    • This works for the session, but they both reset back to "conf" when the file is reopened
  2. Looking for the ~/.vimrc

    • I don't seem to have one, since I typically edit this file as root
  3. yum remove and reinstall of vim
    • no change.

I know that there are a lot of posts regarding similar issues with vim syntax and filetype problems, but I cannot figure out how to resolve mine. My guess is that there is a mapping somewhere that says this one particular file should be recognized as a "conf", but that's all I've got. tia.

edit: to clarify, what I would like to know is how this one file got "stuck" on the "conf" syntax and filetype, whereas all of the other .conf files are "apache" syntax and filetype.

I would recommend using a modeline. Put this at the top of your file:

# vim: ft=apache

If you do not have a .vimrc file, you can create one. Keep in mind that each user has a separate .vimrc in their home folder. You can also look for the system default vimrc (without a dot) located in your vim installation folder. To find out where that is, type :echo $VIM in vim.

If you do create a new .vimrc for your user, you can set all .conf files to have apache highlighting as follows:

au BufRead,BufNewFile *.conf set filetype=apache

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM