I’ve only finally just started using Neovim’s terminal. Vim 8 has this too of course, but it was Neovim that championed it and included it by default.
I switched to Neovim about a year ago to see if there was anything missing compared to Vim. I find Neovim fascinating purely because of how faithful it is to Vim. They had the perfect answer to open source – “if you don’t like it fork it” and make your own. Vim itself is healthier because of the additions that Neovim included.
I literally can’t visually tell if I am using Vim or Neovim. You have the one initial setup to use your existing
.vimrc file and the rest just works perfectly.
I’ve never had to raise a bug because of some incompatibility. All the Vim plugins I use work.
The sheer scale of porting an editor that has been around for 30 years to implement what appears to be 99.9% of it’s functionality is amazing.
One of the big things of Neovim was its inclusion of a terminal.
I’d tried the terminal a couple of times but I found it jarring, it’s like the Vim experience all over again – you’ve no idea how to quit.
You need a combination of
Ctrl + \,
Ctrl + n, which is just as insane as
:wq for those who don’t know Vim. I don’t know whether it’s an intentional homage, but all I know is that it scared me off for a year.
Somewhere during that year I tried tentatively again and added this (probably from this Vi StackExchange answer) as suggested to my vimrc:
" terminal easy escape tnoremap <Esc> <C-\><C-n>
But then I just left it there. I always just kept a separate terminal open to run the commands I needed there. This currently is running a bunch of node docker containers. This obviously means
alt + tab between the windows, or
ctrl + pg up/pg down if you have terminal tabs (I’m using Ubuntu mostly).
However I kept seeing my colleagues running their terminal session within VS Code. I’d roll my eyes at the wasted screen space, but it did seem kind of natural, you have another step in your development process combined into the one editor.
I was always a fan of “Linux is my IDE” so I also didn’t see a problem of switching to the terminal, it also feels ‘fairly natural’ as both Vim and any other terminal programs are still running in the terminal, so I saw it as a benefit of Vim.
It always seemed natural that if you’re running a terminal process you should open up an actual terminal, not some emulator, get yourself the real thing.
However there’s a few niggles:
- Searching the terminal output, there are ways but they aren’t as nice as the Vim searching
- Scrolling naturally around the output, to the top and back to the bottom – especially when its 10,000+ lines long of log output
- Copying and pasting between the terminal output and Vim
- It janks either wasting the screenspace of the terminal tabs or having to
alt + tabto search for the other terminal window
So I dived in again a couple of days ago. Having the
Esc remapping is so natural, I’d forgotten that I’d added it to my vimrc and was simply the first thing I’d tried to get out. I had to go searching for it again just cause I remembered the frustration of quitting from before and didn’t understand why it was so easy.
But now, suddenly it’s awesome. Once you’ve hit
Esc it’s just another buffer. It can hide amongst my hundreds of other buffers, so no screenspace wasted. This obviously assumes you’re using Buffers not ‘Tabs’ (aka Tab Pages).
It resolves all the problems above:
- Searching – I now have my standard
\command to search and highlight plus grepping/ripgrep/fzf
- Scrolling – now again all the
Gbottom commands are so much nicer to use, I never feel the need to use the mouse to scroll aimlessly amongst the text, I can always use
Ctrl + f/gand
j/ktoo – all the lovely Vim commands are now available
- Copying and pasting is just Vim buffers no need for the external clipboard
- As it’s all just buffers is no wasted screenspace and it’s easy to switch to with buffer switching.
So where as I understand it’s just an emulator, not the real terminal, but bash is kind of designed to emulated so not a real problem I guess and now I get terminal + evil mode!
So thanks again Neovim for adding this in.
Steps of caution
There are some peculiarities of Neovim terminals to get used to.
Escis sometimes used in the terminal for genuine reasons, for example cancelling an
fzfrequest – this now won’t work
- The inception of running Vim via an SSH session inside a Vim terminal has a few niggles, but handles pretty well.
- It’s a bit hard to re-find your terminal if you’ve got a couple open – you need to remember the buffer number mostly
- If you close Vim you’ll kill all the processes running there without warning