

Let's just quickly set up a rails app for demonstration purposes. We can easily switch back to it again with the :b bash command: :b bashĪnd we're just in time to see the installer process completing. The terminal buffer shows up in the list. We can close the window containing the terminal buffer.Īny processes that are running the terminal will continue to run even while the buffer is not visible. I'm just going to launch an installer, as an example of a long-running process. We can switch the focus between these splits using the usual window switching commands. Let's open another file in a split window: :split abstract.md

So we can quickly switch back again by pressing control-caret. Our terminal buffer is now the alternate file for this window: :ls We can switch to Normal mode, move our cursor to a filepath, then quickly open the file under the cursor by pressing gf. The gf command works fine in terminal buffers, so if we run a command that outputs filepaths: ls -d1 ~/.config/nvim/*
#OPEN TERMINAL WINDOWS#
Split windows and hidden terminal buffers In another video, we'll look at how we can create a mapping to make the escape key exit Terminal mode. Remember: in Terminal mode, NeoVim forwards all keys to the underlying program, the only exception being: control-backslash-control-N, which is how we get back to Normal mode. When we use the escape key in Terminal mode, NeoVim forwards it to the shell. When I first started to use NeoVim's terminal emulator, I found myself trying to use the escape key to exit Terminal mode. Using these keys in a terminal buffer will switch to Terminal mode, but the cursor always resumes from where we left off. In a regular text buffer, we can use shift-A to insert at the end of a line, or shift-I to insert at the start of a line. Switching between Normal and Terminal modesĪny time we want to switch back into Terminal mode, we can do so by pressing the i key. In effect, all of the text in a terminal buffer is readonly, apart from the current command line which may be edited while in Terminal mode. :reg "īut if we attempt to use any commands that would modify the text in the buffer, NeoVim shows us an error message:Į21: Cannot make changes, 'modifiable' is off We can switch to Visual mode and make a selection.Īnd we can use the y command to copy text into a register. We can scroll the terminal buffer up and down a line at a time using control-e and control-y. In Normal mode, we can move the cursor using all the usual motions. Interacting with a Terminal buffer in Normal mode There's one single exception: if we press control-backslash then control-N, we'll switch back to Normal mode. Notice that at the bottom of the screen it shows that we're in TERMINAL mode.Īs long as we're in this mode, all keys and chords that we press are sent to the terminal emulator. Let's fire up another terminal emulator: :terminal When we exit the shell, the terminal emulator closes and NeoVim switches us back to a regular buffer.

We can run commands in the shell as usual. Now we're running a shell inside of our text editor. In NeoVim, we can launch a terminal emulator by running the :terminal command.
