Posts Tagged ‘gvim’

HTML syntax highlighting for Silverstripe .ss template files in vim

Posted in silverstripe, vim, xhtml on August 4th, 2009 by David – 1 Comment

By default vim opens .ss files with some other file format syntax highlighting.

To enable HTML (actually XHTML) syntax highlighting on your .SS Silverstripe template files, create (or edit) your ~/.vim/filetype.vim file. Then enter this:

au BufNewFile,BufRead *.ss      setf xhtml

Then open a .ss file and it’ll give you nice HTML syntax highlighting. And because it’s in your home directory, it’ll keep working even after you upgrade vim.

Strip <span> tags from HTML in vim

Posted in vim, xhtml on April 6th, 2009 by David – Be the first to comment

When upgrading a website you might see source code like this:

<span style="font-family: Arial; color: #0000ff; font-size: small;">Some text goes here</span>

You’re using CSS now and all those <span> tags are ruining it. In gvim, do this search and substitute:

%s/<span.\{-}>//g

Then to get rid of the </span> tags, do this:

:%s/<\/span>//g

Strip ^M from file in vim

Posted in vim on February 20th, 2009 by David – Be the first to comment

If there are ^M at the end of every line when you view them in vim, you can do this:
:%s/^M//g
To get the “^M” bit, hit ctrl-v and then ctrl-m.