8

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 2

12

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?.

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.