You can do this with one command :
:1,.s/<C-r><C-w>//gn
Decomposing :
:1,.s/ " start a substitute command from top of the document to current line
<C-r><C-w> " paste the content of the word under the cursor
// " replace with noting
gn " don't actually replace
And in normal mode you can create a mapping for better use :
nnoremap <leader>n :1,.s/<C-r><C-w>//gn<CR>
See :h c_<C-R>_<C-W>
for further references.
Edit
If you want to rely on your previously entered search pattern, you can replace <C-R><C-W>
by <C-R>/
. As the /
register is the search register, it contains the last search pattern.
(3/5)
in the statusbar, although it counts matching lines, not matches.