0x822a5b87
0x822a5b87

Reputation: 507

how to automatic generate local variables like IDEA in vim

in IDEA, when we write

new StackOverflowQuestion()

there is a really convenience way to generate local variable:

enter image description here

then we get:

enter image description here

Is there such a vim plugin to help me automatic generate local variable?

Upvotes: 0

Views: 153

Answers (1)

snahor
snahor

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

Related Questions