Couple of examples that I encounter quite often.
Indenting some code
E.g. I want to put code block inside if statement:
puts("hello");
puts("world");
I enter if (pid > 0) { before the first line, then press Esc,j,Shift+v,j,>:
if (pid > 0) {
puts("hello");
puts("world");
Now cursor is at the beginnig of the first puts and to enter closing bracket I need one extra j to go to the end of the indented block.
Pasting block and adding to end of it
Almost the same example. When extracting some code to function, after pasting it with p I need to append return statement or closing bracket at the end. If I’m lucky there will be empty line after pasted block and I can use } to jump right there, but it’s not always the case.
Question
So the question is how to jump to the end of the selected block after some operation performed on it (pasting, indenting, etc)?
Will move you to the end of yanked or previously changed text.
See