1

When using the :oldfiles command, I can easily exit the list with q.

When I use the :registers command, it says "Press ENTER or type command to continue". But I would like to exit the list with q, without entering into macro recording which is annoying. I don't like pressing enter.

Is there a native Vim way to exit the register list with q, just like the :oldfiles "pager" does? It would be nice to have a bit of consistency.

EDIT

To display registers, I actually do :reg "0123456789, which is a short output, so that's why Vim's "more-prompt pager" is not used (cf. :h more-prompt). I have a lot of :oldfiles, so that's why Vim's "more-prompt pager" is used in this case.

I want to be able to always hit q regardless of whether the output is short. Maybe there is a way to always force the "more-prompt pager"? Or to customize mappings for output windows? Worst case scenario I could pipe the output in a scratch buffer that has a custom q mapping, if there is no simpler solution.

2

The difference is whether the whole list fits in the screen or not. If your screen is tall enough, the output of :registers will fit in the screen, and you will see the message “Press ENTER or type command to continue”. If the output of :oldfiles is long enough, you will need to scroll and will instead see the message “-- More --”.

Once you scroll to the end of the :oldfiles output, you will see the same behavior as with :registers, so Vim is being consistent.

In the output of :registers (or any time “Press ENTER or type command to continue” is shown), pressing b, u, k, or will change the message to “-- More --” and you will be able to use q to quit the list. It’s probably not the answer you’re looking for, but it does help to explain to explain the behavior.

  • Makes sense, now I understand why this happens to me, since when I display registers I usually do :reg "0123456789, which has a short output. – Jerome Dalbert Mar 15 '17 at 20:33
2

I can press q at Press ENTER or type command to continue to quit.

If that does not work for you, look at :help press-return - you can also use <space> to continue.

   Press ENTER or type command to continue

This message is given when there is something on the screen for you to read,
and the screen is about to be redrawn:
[..]

-> Press <Enter> or <Space> to redraw the screen and continue, without that
   key being used otherwise.
  • If you press q at Press ENTER or type command to continue, it will quit, but it will also begin recording a macro if you type a letter right away. – Jerome Dalbert Mar 15 '17 at 20:24
1

I gave in to the dark side and used some hacky Vimscript:

map <silent> '' :call DisplayRegisters()<cr>

function! DisplayRegisters()
  redir => output
  silent exe 'reg "0123456789'
  redir END
  new
  silent file [Registers]
  setlocal nonumber norelativenumber
  setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted nomodified
  silent put =output
  silent normal gg"_d2j
  exe 'resize ' . line('$')
  map <silent> <buffer> q :q<cr>
  map <silent> <buffer> <esc> q
endfunction

This allows me to see a short list of registers by typing '', and close it by typing q, just like I wanted.

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.