3

Neovim has a very handy terminal emulator.

In normal mode, I can use all the read-only vim commands on the output, like scrolling or going to the file under the cursor.

But more often than not, I want to delete some lines. Is it possible?

  • What does the documentation say? – romainl May 21 '16 at 6:19
  • I have read all the documentation. I know the buffer is unmodifiable, and I am interested in workarounds or tips that people used to overcome this limitation. – Jerome Dalbert May 22 '16 at 2:11
  • 1
    How about, since you can use read-only command, copy part of the output you want, and paste it in another buffer. I guess it doesn't make sense to try to delete output of the terminal inside the terminal mode. But it surely does to copy the output for later use. – nobe4 May 23 '16 at 6:47
3

You can use this mapping to copy the content of the terminal buffer into a new buffer:

tnoremap <C-U> <C-\><C-N>:%y \| vertical new \| normal! P<CR>

<C-\><C-N> goes back to normal mode so you can use any normal mode command you want.

:%y copy the content of the buffer.

vertical new create a new vertical split.

normal! P paste the previously yanked text into the buffer.

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.