Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto formatting for vi?

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)

like image 810
Allain Lalonde Avatar asked Jan 20 '09 23:01

Allain Lalonde


3 Answers

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

like image 175
dwc Avatar answered Nov 14 '22 05:11

dwc


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

like image 26
Greg Hewgill Avatar answered Nov 14 '22 05:11

Greg Hewgill


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.

like image 3
sth Avatar answered Nov 14 '22 06:11

sth