3

In vim when I want to indent a section of code, I typically enter Visual mode and then use < or > to change the indentation. After doing that, vim puts me on the first line of the code that I indented.

Often the next thing I want to do is add code to the end. How do I quickly jump to the end so I can hit o and start adding more code?

I know I can type gv[esc] or gvo[esc] (depending on whether I had started my block from the beginning or the end) but I'm hoping for something more vim-like (i.e. not so many keystrokes).

2 Answers 2

7

Ooh, I found the answer to my question. I can do either one of these:

'>
`>

The first one jumps to the last line of the previous visual selection.

The second one jumps to the last character of the previous visual selection.

After either one of these I can hit o to start adding more lines.

0

Brian's answer didn't work for me. To be explicit, I executed the following:

Shift-V
j
j #highlighted three lines in visual mode
'> #expected vim to indent, and then put me on the last line of the selection - instead, nothing happened (no indent, still in Visual Mode)
`> #expected vim to indent, and then put me on the last character of the selection - instead, I was just moved to the last character of the selection (no indent, still in Visual Mode)

The best solution I've found is

Shift-V
j
j #etc.
>`` #this indents and then jumps to the final line

Executing >'' as the final command has the same effect.

2
  • Just because you've earned a privilege on one SE site doesn't mean you should have it on all sites. Once you earn 200 rep on one site, you get an association bonus though, which will give you enough rep to comment on any other site. Commented Nov 27, 2013 at 14:00
  • @scubbo But I think Brian means that you do an indent first, ie: V j j > '> Commented Nov 25, 2016 at 9:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .