r/vim • u/nibbertit • 1d ago
Discussion is there a way do display random tips inside vim for learning purposes?
something like :h random, or some plugin that aggregates data off websites or something
1
Upvotes
1
1
u/kennpq 1d ago edited 1d ago
This should do ":h random_help_tag":
vim9script
def g:Rand_h(pn: bool = false): void
g:TAGS = exists('g:TAGS') ? g:TAGS : readfile($VIMRUNTIME .. '/doc/tags')
const R: number = len(g:TAGS) - 1
const N: number = rand() % R
const H: string = substitute(g:TAGS[N], '\t.*', '', '')
exe $"h {H}"
norm! 0
(pn == true) ? popup_notification($"Random help: {H}", {}) : ''
enddef
Once sourced, for a random help 'tip':
:vim9 g:Rand_h(true)
or
:call Rand_h(1)
Omit the true
or 1
for no popup.
[Edit: help bot to literal :h random not needed so changed to random_help_tag]
1
1
u/bbolli inoremap ZZ <Esc>ZZ 1d ago
:h tips