开发者

How to jump down X amount of lines, over and over

I'm using 10j to jump down 10 lines, but I want to easily jump 10 lines over and over. I don't want t开发者_如何学编程o have to perform the jump with a macro qv10jq@v@@..

I wish there was a method for repeating down keys like motion has f then ; to continually jump (, to go back) to the next character(s).

is there anything shorter than my macro?


Instead of 10j, you can run:

:+10

Then you can repeat the last ex-mode command with @:.


Here's repmo.vim - a plugin to do what you want. It maps ; to repeat the last motion command given with a count.


The solution to this gave me the idea to use noremap to map 10j (or any other number) and 10k to my up and down arrows. I don't know if anyone would be interested in something obscure like this but figured I would comment.

added to .vimrc:

noremap <Up> 5k
noremap <Down> 5j


There is no plugin or edit to .vimrc here, but I've found this simple and low tech method works pretty well because it requires no control keys and you can keep both hands stationary while scrolling up or down in any increment of lines or order (e.g. down, down, up):

Let's say you want to move down in increments of 44 lines at a time.

44j   (of course)

Now just leave your left index finger above the "4" key and repeat this to continue scrolling down in increments of 44 lines. Although it's 3 keystrokes, you can do this very quickly as long as you stick to numbers like 22, 33, etc.

Now what is nice about this is that you can quickly reverse direction with no hand movement by just hitting "k" instead of "j", e.g.

44j
44j
44j   (oops, too far, lets go back now...)
44k

Also, you can start with a higher number like 55 (for speed scrolling) and then drop to 22 or 11 to home in on your target. Unfortunately numbers like 77 don't work as well b/c you want to do the number with your left hand, although you could still do higher numbers like 77 with your left hand, it's just that you have strayed from standard touch typing hand position at that point.


Try ctrl+f to move a whole page down and ctrl+b to move a whole page back. Not necessarily 10 lines though.

Taken from this site: http://www.thegeekstuff.com/2009/03/8-essential-vim-editor-navigation-fundamentals/


I found that mapping 10char jumps to arrow keys work perfectly for navigating. ( ^d, ^u, ^f, & ^b are too big of jumps for my liking). Just paste this into your .vimrc file :)

noremap <Up> 10k
noremap <Down> 10j
noremap <Left> 10h
noremap <Right> 10l

Alternatively, you can map the custom jumps to replacing any of these: ^d, ^u, ^f, & ^b, such as:

map <C-d> 10j
map <C-u> 10k


There's a great solution in this answer:.

I found this to have some excellent info:

:help scroll-cursor

The thread also references:

:help motion.txt

You can configure how many lines to move at a time by for example: 15<C-d>

Then subsequent <C-d> or <C-u> strokes will move by the same amount of lines

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜