Yeri's Digital Note

Vim pro tips: move like a ninja!

November 21, 2017

“Smooth” Scrolling

Vim default scrolling behaviour is terrible. <c-f> to scroll one page down, <c-b> to scroll one page down, these feature is just not right. I get lost easily. It makes me dizzy. It also has another pair of commands, <c-d> and <c-u> to scroll up and down half page, but is no better than the previous.

badmove.gif

wtf. So I made my own version of smooth scrolling. I came out with these pairs of mapping nnoremap J 10gj nnoremap K 10gk vnoremap J 10gj vnoremap K 10gk

muchbetter.gif

Much better.

Horizontal jump

We use w or e and b to leap one word. Why don’t we give it a boost? nnoremap E 20l nnoremap B 20h vnoremap E 20l vnoremap B 20h Now watch, I can jump around like a ninja!

horizontal.gif

How cool is that?

Crazy fast window movement

This is a classic tips but extremely useful, you’ll love it soon or later. nnoremap <C-h> <C-w>h nnoremap <C-j> <C-w>j nnoremap <C-k> <C-w>k nnoremap <C-l> <C-w>l

windo.gif