Fandom

Vim Tips Wiki

Change filetype based on directory path

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Tip 742 Printable Monobook Previous Next

created 2004 · complexity basic · author Michael Pyne · version 6.0


I recently installed pyblosxom to do blogging, using Vim to edit blog posts. Pyblosxom automatically transforms .txt files under a certain path into HTML, RSS, or whatever else is appropriate. These .txt files will probably contain HTML, so if you would like to tell Vim to use a different syntax highlighting style for files under a directory path, try adding this to your vimrc:

autocmd BufRead,BufNewFile ~/.pyblosxom/data/* set syntax=html

CommentsEdit

As an aside, another way to go about this would be a user command that gives you a skeleton entry, saved and named (for instance current time/date stamp) as you desire with your cursor placed where you want. File format, patch mode and other such options can be set as desired as well.

Also on Fandom

Random Wiki