2

When I hold the key k to move cursor up, is it possible to speed up the cursor movement?

I know that I can combine number with command (like: 20k) to move up many lines, but sometime I just prefer to hold the key to move.

Lai32290
  • 275
  • 1
  • 9

2 Answers2

4

I think you might not be asking the right question.

First you should have a read at Rich's answer on the question Usage of timeoutlen and ttimeoutlen. If your issue comes from a mapping that will be useful knowledge. Understanding :h 'timeout', :h 'ttimeout', :h 'timeoutlen' and :h 'ttimeoutlen' is always useful.

But I think your problem is actually one of these:

  • Either your keystrokes are not registered fast enough, and that's not a Vim issue.
  • Or you need to learn how to efficiently navigate in Vim.

For the first issue you might solve your problem at the terminal or the OS level. One option on Linux is to tweak xset to change the repeat rate of your keystrokes. For example by adding something like this xset r rate 150 50 in your profile file. You can refer to man xset to get more details. Or maybe your OS as a setting to change the frequency in it's UI, or maybe you can change this setting in your keyboard firmware. In any case this is not something you will fix only in Vim.

Now the most likely option: You need to learn how to use Vim properly.

Being able to navigate in a file with hjkl (either by keeping the key pressed or using a count like 20j) or even using :set number and :set relativenumber is a good start but that will always slow you down.

Vim was made to make navigating a file efficient, that's why there is a normal mode and that's why there is a plethora of available motions. In the help file :h motion.txt. For example in the :h up-down-motions you will find a lot of different motions with different ranges (i.e. some of the motions allow you to precisely move the cursor in a short range while others allow you to move the cursor less precisely but further away to explore a file). In addition to that :h scroll.txt is quite useful to learn additional ways to move your cursor in a file without having to keep j pressed all the time.

There are also a ton of resources out there to learn how to navigate in Vim efficiently. I think with these resources you shouldn't need to change the frequency of your key repetitions.

statox
  • 49,782
  • 19
  • 148
  • 225
  • Thank you! you're right, I think what I'm trying to do is a little bit deep than what I was expecting for. I didn't expect it could be related to my terminal, but it make total sense.

    I gonna try to use scroll motion, it seems work for what I need, thank you so much again.

    – Lai32290 Feb 16 '22 at 18:30
  • 1
    Indeed, my preferred keys these days are C-u, C-d, and / – D. Ben Knoble Feb 16 '22 at 20:00
2

I don't know the answer to your question (I suspect it's not possible...). But I'm sure many would agree that the 'answer' is to use the 20k method (you can put set relativenumber in your .vimrc to make this easy to do).

There are so many ways to move up and down. See :help up-down-motions.

mattb
  • 1,111
  • 4
  • 15
  • Hey, thank you, I gonna have a read about this up-down-motion, specially for the scrolling part, it seems work for what I need, thank you so much – Lai32290 Feb 16 '22 at 18:30