Is there a way to let gVim Autoformat my (c#) code? I’m not just talking about indenting, but actually formatting.
Like changing
public void Program() {
...
}
to
public void Program ()
{
...
}
and the other way around. Be it a macro, plugin or something else (formatexpr?).
I’m trying to imitate the Visual Studio formatting here. I’d love to type } and have everything look nice.
Vim has no native way to do that. However you might be interested in AStyle which has many options
astyle --helpwill tell you what options are available. Many presets are available.In vim you can filter a document with
:%!commandwhere command receives the current buffer in stdin; the current buffer is replaced with the output of your command. If the command does not read from stdin but expects a file name as argument instead, use%.Thus:
will do it (provided you replace with the good path).