vim macros - vim to generate code template dynamically -
i have write test cases contains repetive code.
- the name of method should classname delimitted _ ex: class_name_test
- the object name should classnameobj , mock method should take classname.class
- the genericobj.call statement common methods sayhello should bound classnameobj , remaining result common
- the commonmethods common objects
instead of copy pasting , changing classname , classnameobj, interested in automating using vim. is possible if pass class name, rest should generated?
the method template mentioned below.
@test public void stop_video_request_valid_data() throws throwable { classname classnameobj = mock(classname.class); when(genericobj.call()).thenreturn(new object[]{classnameobj}); when(classnameobj.sayhello()).thenreturn("hello"); commonmethods(); }
snippets built-in :abbreviate
on steroids, parameter insertions, mirroring, , multiple stops inside them. 1 of first, famous (and still used) vim plugins snipmate (inspired textmate editor); unfortunately, it's not maintained more; though there a fork. modern alternative (that requires python though) ultisnips. there more, see this list on vim tips wiki.
there 3 things evaluate: first, features of snippet engine itself, second, quality , breadth of snippets provided author or others; third, how easy add new snippets.
Comments
Post a Comment