Sometimes I want to dump outputs of a command -internal or external, to a buffer in NeoVim.

Let’s take map command as an example.

As you may already know, map is an internal command which lists what is mapped.

To see if a particular key -leader as an example, has already been bound we run:

:map <leader>

You can use a specific mode to narrow your scope:

  • :nmap for normal mode mappings
  • :vmap for visual mode mappings
  • :imap for insert mode mappings

In order to see all keymaps we run:

:map

This output usually will be long and complex. In order to see all my keymaps in a searchable buffer run below command:

:enew|pu=execute('map')

Info

For Vim user, execute commands requires Vim 8+

You can also use vertical splits with :vnew.

If you want to dump the outputs of an external command, you can run it like below:

:enew | .! <command>
" or
" :enew | read !<command>

All done!