Rory's Blog
Home
Blog
Projects
Facebook
Google+
Github
RSS

Vim HTML Setup

08/06/14

This post is a long time coming.. I've been putting it off for no good reason because it shouldn't take that long to write or do the changes to my vimrc setup.

Okay, the problem: I want tab to represent two spaces for HTML files (and various other files but the main concern for now is HTML). Currently, I have it set such that tab is 4 spaces. This creates a couple tiny annoyances when I'm actually writing HTML documents the way I want them written (with each nested item indented two-spaces).

So, let's make it so that for *.html documents, tab is 2 spaces so these problems go away.

Googling. Helpful page.

So, make a ~/.vim/ftplugins/html.vim and put in my desired html-specific settings.

setlocal tabstop=2
setlocal softtabstop=2
setlocal shiftwidth=2

And now it is no longer annoying to TAB when writting in HTML. I just need to fix my habit of using the spacebar instead of tab when writing in HTML now.

Yay.