1

Some times I need to navigate through a new file, and I need constantly type 10j or 20j.

I'm wondering if there is a short-cut or some kind of config which allows me to press only 1 key to repeat the last movement.

I've searched online briefly, but no obvious solution yet.

Is there any way to do that?

Zen
  • 4,381
  • 5
  • 29
  • 56

2 Answers2

3

You can use <C-d> and <C-u> to scroll down and up by half-screens.

Also, <C-e> and <C-y> (scroll down and up) can take a count so:

nnoremap <key>      10<C-e>
nnoremap <otherkey> 10<C-y>

There's also this very simple way to get an actionable outline of the current buffer:

:g/func/#

then do :23 to jump to the corresponding line.

romainl
  • 186,200
  • 21
  • 280
  • 313
1

you can save it to a register.

  1. type q and then type a register, let's say z.
  2. type 10j
  3. type q to exit motion.

then when you want to do 10j next time, simple type @z.

qqibrow
  • 2,942
  • 1
  • 24
  • 40
  • type @ require `shift + 2`, besides, this is still 2 key stroke. – Zen Jan 21 '15 at 07:31
  • sorry. my fault. I searched this a little bit and find this. http://superuser.com/questions/429917/repeat-last-normal-mode-command-including-moves-in-vim – qqibrow Jan 21 '15 at 07:40
  • 1
    If you use macros, there is `@@` that repeats the last macro that was executed. It is faster than `@k` each time where `n` is a key. I find it quite useful! – Plouff Jan 21 '15 at 07:46