Reputation: 98
How would i assign my own indentation margin if a condition is met (ie string is included) on the previous line? An example would be one space indentation in an if statement. thanks in advance.
input:
`int main(int argc, char **argv) {
if (argc != 1) return(2);
if (argc != 2)
return(3);
for (...)
printf("\n");
}`
output:(using g/if/normal j>>) shifts to the right every return line
output:(expected)
int main(int argc, char **argv) {
if (argc != 1)
return(2);
if (argc != 2)
return(3);
for (...)
printf("\n"); }
In other words the positioning is expected to be relative to the string, and not its previous position. again, thanks for your effort @kev
Upvotes: 4
Views: 493
Reputation: 2592
:help indentexpr
You need to create a indent function.
I've used the following reference before. How to Write a Vim Indent Script
You can also look in the indent folder of your vim install for examples.
on Max OS X
/usr/share/vim/vim73/indent
Upvotes: 2