1

My goal is mapping n to nzz and keep the count on the status bar.

Based on maparg reference from here, I have tried this:

:exe 'nnoremap n nzz' . maparg('n', 'n')

It actually adds zz, changing the default behavior of the n key, but it makes me lose the count, let's say: [3/15] in the statusbar.

1 Answer 1

1

zz will remove the count display ([n/nn]) in the statusbar if the view is changed. A quick and dirty solution to show the count again is to hit n or N again, ie.

nnoremap n nzzNn

Edit: If one would like to call additional functions, say FlashCursorLine(), insert that before Nn, as user Biggybi suggested in the comments, for example,

nnoremap n nzz:call FlashCursorLine()<CR>Nn
3
  • If I have a function to flash the cursor line, can I also add it? Would you have any idea about adding it on the map? The mentioned function is this: pastebin.com/q355Mbmh Mar 6 at 17:21
  • 2
    @SergioAraujo you should only need to append :call FlashCursorLine()<cr> to your mapping (or maybe put that right before Nn).
    – Biggybi
    Mar 7 at 1:33
  • I have updated the mentioned pastebin code for those who would like to test this approach: Each 'n' moves the cursor to the center of screen and flashes the cursorline. Mar 7 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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