Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7079915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:43:49+00:00 2026-05-28T06:43:49+00:00

If I have an apache file in /etc/apache2/sites-available/www.example.com and I set its filetype like

  • 0

If I have an apache file in /etc/apache2/sites-available/www.example.com and I set its filetype like so

:set filetype=apache

What does that do? Does that change the file at all? Is it only reflected in the instance of vim? The session of vim? I can manually set the filetype, but then vim warns me that I am in read only mode (/etc/apache2 needs root access). If I open vim as root, I won’t get the warning, but if I leave and open it again (as normal or root), the filetype is gone. How do I make this more permanent, at least when called from the same session file

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:43:50+00:00Added an answer on May 28, 2026 at 6:43 am

    set filetype changes the way vim handles the file, by invoking all the FileType autocommands. It does not persist. If you want to always open that file with filetype=apache, try adding this into your .vimrc:

    au BufRead,BufNewFile /etc/apache2/sites-available/www.example.com set filetype=apache
    

    You can read more about it in:

    :help 'filetype'
    :help filetypes
    :help :autocmd
    :help .vimrc
    

    EDIT: as found in my /usr/share/vim/vim73/filetype.vim:

    au BufNewFile,BufRead access.conf*,apache.conf*,apache2.conf*,httpd.conf*,srm.conf* call s:StarSetf('apache')
    au BufNewFile,BufRead */etc/apache2/*.conf*,*/etc/apache2/conf.*/*,*/etc/apache2/mods-*/*,*/etc/apache2/sites-*/*,*/etc/httpd/conf.d/*.conf*        call s:StarSetf('apache')
    

    s:StarSetf will setfiletype to apache if the filetype doesn’t match an ignored pattern. On my system, :echo g:ft_ignore_pat will show only archive file extensions as ignored. setfiletype does set filetype, but only once.

    So, at least on my system, the pattern */etc/apache2/sites-*/* would catch your filename and make it an apache file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm configuring Apache and the setup documentation has me creating a file in .etc.apache2/sites-availible
I have DocumentRoot /var/www/test in my .htaccess file. This is causing the apache server
My site was working fine until I followed this guide, http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-ubuntu-9.10 to set up
I have a file test.py at /var/www and I am using apache2 on ubuntu
I have a file like this <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/ <Directory />
I have a java app that uses log4j. Config: log4j.rootLogger=info, file log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.File=${user.home}/logs/app.log log4j.appender.file.layout=org.apache.log4j.PatternLayout
I have the following in a java file (MyRtmpClient.java): import org.apache.mina.common.ByteBuffer; and ByteBuffer is
I have apache and mysql set up on my local machine (Mac). Whenever I
I've been testing usage of apache authentication, following this example . I'm using Ubuntu/Apache2.
I have apache 2.2 and tomcat 5.5 running on a Windows XP machine. Which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.