I am pleased to announce that my work with eclipse’s CDT parser has finally come to some form of fruition. I’ve marked this release as a major version 1.31.0 (both the Viable Core and Viable CDT features) to celebrate this work.
It is now possible for users of CDT to leverage it to introduce additional text objects in Viable that are not available in Vim. Currently, v1.31.0 implements one trivial example. In the future I hope to introduce many more text objects and motions that use CDT, JDT and possibly PDT (python.)
Viable introduces the text object for function parameters both in function calls and in function declarations. The default binding for this text object is ic. I illustrate its use with an example, suppose you have the C code
/*
* main.cpp
*
* Created on: 2011-07-04
* Author: matt
*/
#include <stdlib.h>
int func1(int v1, int v2)
{
/*no-op*/
}
int main(int argc, char **argv ){
func1( func1(1,2), func1( 1+2/3, (4+5)/(4-6) ) );
return EXIT_SUCCESS;
}
and suppose that you wish to change func1( 1+2/3, (4+5)/(4-6) ) to func1( (4+5)/(4-6), (4+5)/(4-6) ). Let | denote the cursor position, then you can place the cursor func1( 1+2/3, (|4+5)/(4-6) ) and type yic which will yank the parameter (4+5)/(4-6), then you can place the cursor func1( 1|+2/3, (4+5)/(4-6) ) and type vicp which will visual select the first parameter and paste over it giving you the result. This text object also works for function declarations.
Suppose now you wish to change func1( func1(1,2), func1( 1+2/3, (4+5)/(4-6) ) ); to func1( func1(1,2), 0 );. Placing the cursor func1( func1(1,2), fu|nc1( 1+2/3, (4+5)/(4-6) ) ); and typing cic0 gives the desired result. Similarly, so does vicdi0 which is rather longer but does the same thing with a visual selection.