Reputation: 507
in IDEA, when we write
new StackOverflowQuestion()
there is a really convenience way to generate local variable:
then we get:
Is there such a vim plugin to help me automatic generate local variable?
Upvotes: 0
Views: 153
Reputation: 1201
You can achieve that with any snippet engine. I suggest you to check vim-snippets too (https://github.com/honza/vim-snippets/).
This may not be exactly what you want, but check this line: https://github.com/honza/vim-snippets/blob/master/UltiSnips/java.snippets#L51
Assuming you are using ultisnips + vim-snippets:
Write o -> o
Press <Tab> -> Object var = new Object();
Write Foo -> Foo var = new Foo(); // note: you write Foo once
Press <C-b> and write foo -> Foo foo = new Foo();
If you want something like new Foo()
to get transformed into Foo foo = new Foo()
you will have to write your own snippet, it shouldn't be that hard.
Upvotes: 1