1

Suppose I have many lines of various indentations. E.g.

qqqq
      wwwwwwww
    eeeeee

      rrrrrrr
   tttttt
        yyyyyyy

If I am anywhere on the fourth line above which is blank. Is there a shortcut to jump the cursor to directly under the first e of the third line?

1

I don't believe so. Does the blank line have whitespace or is it totally empty? If the former you can use something like this:

:nnoremap <leader>^ kg^j

Or, courtesy of Mass, just

:nnoremap <leader>^ -j

<leader>^ can be replaced with any unused key combo you like. Enter it while in Normal mode and you'll get the effect you need. (If you want it to work with wrapped lines, too, then use gkg^gj)

If the blank line is totally empty there's no easy way to go to an arbitrary column. You have to insert the appropriate amount of whitespace first. (Well, that's a bit of a lie...you can use :set virtualedit=all but that's probably going beyond what you have in mind.)

  • Could kg^ be replaced with -? – Mass Oct 6 '17 at 1:15
  • @Mass yes...good one. One of those that I was aware of at some point but had long faded from memory. It wouldn't go well with the one for wrapped lines, though. – B Layer Oct 6 '17 at 1:58
1

If you have set cindent, you can press S (or equivalently cc) to clear the line and start insert mode at that point. If you want to wind up in normal mode, S <esc> would work, and fill the line with spaces up to and including under the first "e."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.