Search code examples
vimterminalnodemonsimplehttpserverneovim

How to run an ongoing terminal command and have vim open


I do a lot of vim and terminal work. It would be great if I could run a terminal command like http-server or nodemon and then go into vim, make edits in multiplte buffers and quickly switch to look at my terminal for http-server output or nodemon logs, and then switch back to vim.

What is an easy what to do this?

I'm trying to decide between neovim's terminal emulator, I can't quite get ctrl + z and fg to work for me, because putting http-server in the background stops it's function for some reason.

Any other suggestions are welcome too. Ideally I could view my terminal in just another vim buffer.


Solution

  • You can exit neovim's terminal mode with <C-\><C-n> (ctrl-backslash followed by ctrl-n), which puts you back in normal mode with any processes still running.

    I have it mapped to a slightly more convenient key combination (ctrl-left bracket twice):

    tnoremap <C-[><C-[> <C-\><C-n>