I want to reindent an nginx
configuration file with the following simple rudimentary rules:
- a
{
increases indentation - a
}
decreases indentation
The idea is cindent
is just enough to do it. I have the following file:
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
I run vim -u NONE ./thefile.conf
and type gg=G
to apply =
as an re-indenting operator to the whole file and vim indents the whole file by aligning the data below *
to the same column:
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
On the other hand, if I remove the *
star character from the first line, doing =
operator on the whole file re-indents the whole file just fine:
include /usr/share/nginx/modules/.conf;
events {
worker_connections 1024;
}
Removing star characters from the file fixes it - I can indent big files that way. How to tell vim =
command not to increase indentation on *
character when re-indenting the file? Why does *
character break the indentation when using the =
command?
Also, only /*
breaks the indentation. Doing / *
or /something*
does not break it and indentation seem to work fine. Why? I tried to test other characters like &
^
instead of *
, and they didn't have the same effect as *
.
/*
is the beginning of a comment in some languages. What file types are affected the way you describe? – B Layer Feb 2 at 15:14:h format-comments
. It suggests thatindentexpr
may be better thancindent
at dealing with three piece comments (which/*
is part of, i.e. the first piece).'fo'
may also be involved here. What do you have for that setting? – B Layer Feb 2 at 15:23ft=conf
. I will try:set comments=
to something simple, thank you! – KamilCuk Feb 2 at 15:24