Reputation: 132
In Vim, after I wrote this :
int[] no={1,2,3,4,5,6}
I've changed my mind and wanted to make it String like this :
String[] no={"1","2","3","4","5","6"};
It is easy once you move your hands to arrow keys and stay in insert mode. Otherwise you need lots of esc key presses. What is the "Vim way" of doing this?
(there were similar questions, but I think this specific example decently demonstrates the need to an easy way of traversing in insert mode.)
Upvotes: 4
Views: 136
Reputation: 22734
If the 'easy way of editing in insert mode' you were thinking of was
"<Right>"<Right>"<Right>"<Right>...
you can do that in normal mode, too.
f{
.a"<Esc>
.<Space>.<Space>.<Space>.<Space>.<Space>.
...!Upvotes: 0
Reputation: 172738
No, you don't need to stay in insert mode for this. One option with built-ins:
0cwString<Esc>:s/\d/"&"/g
Another with the surround.vim plugin (ysh"
surrounds the character to the left with double quotes):
0cwString<Esc>f,ysh";;.;;.;;.;;.f}.
I'm sure others come up with many more creative approaches...
Compare this with insert-mode:
0cwString<Esc>f{a"<Right>"<Right>"<Right>"<Right>"<Right>"<Right>"<Right>"<Right>"<Right>"<Right>"<Right>"<Esc>
Upvotes: 5