Vim's mark functionality allows one to apply functions to every line between the current line and the marked line. For example if I mark the below line 3
with k
1 var a = 0;
2 while (a < 10){
3 a++;
4 console.log('Hello');
5 console.log('world');
6 █
7 }
and from the cursor position (█
) issue the command >'k
, I will get the following
1 var a = 0;
2 while (a < 10){
3 █ a++;
4 console.log('Hello');
5 console.log('world');
6
7 }
(Note: the cursos might be over the a
, but that's not important)
This is the desired effect, but now the cursor has moved all the way back up. For most cases this is desirable, as I usually want to edit from the top. But in this case, I might want to indent again, so I have to navigate once again to the bottom. In cases where I am indenting 20+ lines this becomes a real chore.
How can I temporarily disable this seek back function?
The simplest solution is to press `` (i.e. back-tick twice) after your command to jump back to the previous location.
After you do >'k just hit '' (single quote, single quote) - not back tick, I think - and you'll go back to where you were.
If you do this often then you can map a key to do it in one:
:map >> >'k''
Then whenever you hit >> it'll do that sequence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With