Tool or script to set the align rules for my code or vim editor
I wa开发者_Go百科nt to align all the declarations of variables, object doesnt matter where they are in the code.
eg.
int i;
for(...){...}
short j;
Instead of me going and aligning the declarations of i and j, can I restrict that variable declaration should start at some particular column number in vim. So if I am planning to declare some variable, it should go and start from some respective column.
It really sounds like you're looking to correctly indent your code, not just move variable declarations to a particular column. This can be done natively with the =
command, which will indent the given lines (unless the equalprg
option is set). For example, to indent all lines in a file, use:
gg=G
which will move to the top of the file, then indent all lines until the bottom of the file. Indentation in vim is actually much more complex than this, as it supports autoindent, tabstops, shiftwidth, different indenting rules for different file types, etc. For details, see the Vim Wiki.
精彩评论