tags:

views:

434

answers:

5

Does an auto-formatting tool exist for vi that'll allow me to define per language preferences?

edit: I'm not looking for syntax highlighting. I'm looking for something that will apply formatting rules to my code. (Like brace positioning, spaces around oeprators, etc)

+7  A: 

Well, there's Vim which comes with a lot of languages covered already and which is easy to customize per language.

dwc
A: 

As Darrin says, "flee from the vi wasteland" and embrace the one true vim path instead! Your desired language preferences, assuming that they're not for SNOBOL or Simula, will thank you!

Edit: Actually extending the syntax highlighting to cover SNOBOL or Simula would not be that hard! (-:

HTH

cheers,

Rob

Rob Wells
+3  A: 

Vim has tons of support for filetype-specific customisations. You might find what you are looking for in there.

Greg Hewgill
+1  A: 

You can use vim. If you're on GNU/Linux, take a look at /etc/vim/vimrc for global defaults. Some things you may want are "syntax on" "filetype indent on" and "set showmatch".

MighMoS
+1  A: 

You can add a file in ~/.vim/ftplugin/ for each file type. For example, set ~/.vim/ftplugin/c.vim to

set tabstop=2 shiftwidth=2

This sets your indentation for C files to two spaces.

sth