I would expect [count]%
to jump back and forth between matching braces count
times or something like that, but instead, typing that command seems to move the cursor to a random place in the buffer. It seems to always go to the same place for constant count
, but different places for different count
. So what exactly does that command do?
2 Answers
From :help N%
:
Go to
{count}
percentage in the file, on the first non-blank in the line|linewise|
. To compute the new line number this formula is used:
({count}
* number-of-lines + 99) / 100
See also'startofline'
option.
I didn't know this either, by the way. But I typed :help %<C-d>
, and N%
looked like a good match ;-)
Also see: How do I navigate to topics in Vim's documentation?.
Plugin Match-Up: g:matchup_motion_override_Npercent
This plugin offers the possibility to use [count]%
for both motions:
{count}%
forwards{count}
times. Requires{count} <= g:matchup_motion_override_Npercent
.- For larger
{count}
,{count}%
goes to the{count}
percentage in the file.
The default value is 6
.
This means
5%
would cycle five b:match_words
, e.g. in vimscript through elseif
.
But 50%
would jump to the middle of the file.