Scrolling while keeping j
or k
pressed is too slow.
Doing 10j
multiple times isn't ideal either.
How can I go faster while keeping a key pressed ? I'm using vim for vscode but I imagine the solution probably applies there too.
Scrolling while keeping j
or k
pressed is too slow.
Doing 10j
multiple times isn't ideal either.
How can I go faster while keeping a key pressed ? I'm using vim for vscode but I imagine the solution probably applies there too.
If you are looking to speed up the time to get to a specific spot, having many pages. These commands support to keep the keys press if needed to increase speed:
ctrl + f (page down)
ctrl + b (page up)
ctrl + d (scroll window downwards, normally half a a screen)
ctrl + u (scroll window upwards, normally half a a screen)
less
, man
and the like without the ctrl
modifier. –
Thurlough I believe you're looking for a better way to navigate between say code blocks or similar sections without having to do recursive j's or k's. These are my personal favorites :
if you're still wanting to explore more navigation tricks and commands, i strongly recommend you to watch this wonderful talk.
Ctrl+e
Ctrl+y
. That's what i needed! Many thanks! –
Variegated There are other good jumps
} .......... jump paragraph forward
{ .......... jump paragraph above
H .......... top of the window
M .......... middle of the window
L .......... bottom of the window
Ctrl-d ...... jumps down half screen
Ctrl-u ...... jumps back half screen
If you make jumps with search /pattern
you can use
Ctrl-o ...... jump to the last position (jump list)
Ctrl-i ...... jump to the next position (jump list)
Relative to use j
and k
, they do not add any entry to the jumplist (:h jumplist), but you can do something that in your ~/.vimrc
:
" It adds motions like 25j and 30k to the jump list, so you can cycle
" through them with control-o and control-i.
" source: https://www.vi-improved.org/vim-tips/
nnoremap <expr> j v:count ? (v:count > 5 ? "m'" . v:count : '') . 'j' : 'gj'
nnoremap <expr> k v:count ? (v:count > 5 ? "m'" . v:count : '') . 'k' : 'gk'
With the above lines in your config file any jump greater than 5 lines will create a new entry in the jumplist.
To make my search faster, because my laptop makes difficult to reach /
I have this mapping:
nnoremap <space> /
In order to start typing on the last inserting point you can type:
gi
You can reselect and jump to the last visual selection with
gv
Once you have a selection you can use the letter o
to jump the selection edges and possible increase or decrease how far the selection goes.
gd ............. jump to function definition
There is also the "changelist"
g; ................ goes to the older cursor position on the changlist
g, ................ goes to the newer cursor postion on the change list
Sometimes you are at the right point, but you want to scrool the widows without moving the cursror.
gg ............ beginning of the file
G .............. end of the file
zt ............ puts the current line at the top
zz ............ puts the current line at the middle
zb ............. puts the current line at the bottom
% .............. Jump to corresponding item, e.g. from an open brace to its matching closing brace.
If you want to open your last edited file on vim you should set an alias like this one:
alias lvim='vim -c "normal '\''0"'
To jump to your last change you can have a map
nnoremap gl `.zz
Now in normal mode you can press gl
and the cursor will jump to your last change point, as we are also using zz
, the line will be centered on your screen.
An annoying thing I had in the past was how fast my Ctrl-d was. To solve this now I have the "vim-smoothie" plugin - for neovim there is karb94/neoscroll.nvim.
An interesting plugin to help you jump faster on the file is vim-sneak, it remaps your normal s
key and shows you a prompt where you type two keys, it will jump to it allowing you to use ;
to jump to the next. (It has a slogan: The missing motion for vim).
© 2022 - 2024 — McMap. All rights reserved.