On Fri, 28 Apr 2006, Justin Randall wrote:
Hi,
I would like to know if there is an easy way to fix the placement of { }
brackets in vim
so that they fall two or three spaces intented. For example in a C++ file I'm
currently
working on, I have:
if (pExample != NULL)
{
// code here
}
What I would like is to have the brackets indented from the edge of the page 2
or 3
spaces. Such as:
if (pExample != NULL)
{
// code here
}
Any ideas as to how I can achieve this?
Assuming your code curly brackets are correctly aligned, and there's
only whitespace before them, you can do
:%s/^\s*[{}]/ &
to add 2 extra spaces in front of every curly bracket on its own line.
HTH :)
--
Gerald