I’m a big Vim fan. I use it for most of my writing and all of my software development. It’s customizable and extensible, and most of all, it’s light-weight.
Vim 8 has a terminal mode which is great if you do content around CLI tools. It makes it so easy to snag the output of programs so you can paste that output into your work. I’ve actually used it to run several commands and then turn that into a tutorial.
To activate Terminal mode, use the
:term command. Vim will open a new window where you can run any CLI command you want.
You can use
CTRL+d or type
exit like a normal Terminal, but that also closes it, meaning you can’t snag its content and use it as a reference.
Unfortunatley, exiting Terminal mode is awkward if you wish to keep the text from the session.
A quick glance at the
:h Terminal-mode command shows that there are a couple of commands you can run:
Use CTRL-W N (or ’termwinkey’ N) to switch to Terminal-Normal mode. Now the contents of the terminal window is under control of Vim, the job output is suspended. CTRL-\ CTRL-N does the same.
So, you’ll have to press
Ctrl+w followed by
N (That’s an uppercase N) to get back to Normal mode where you can edit the text as if it were a regular file. The
Ctrl+n keybaord combination also works, but if you’re like me and use
tmux and Vim with some window navigation configuration options, that key combination won’t work.
To avoid this awkwardness, map it to the
Escape key by adding the following line to your
tnoremap <Esc> <C-w>N
tnoremap sets keybindings only for Terminal mode, leaving your other bindings alone. The only drawback is that you won’t be able to use the
Escape key in your Terminal. You could modify this to use your leader key instead, which is what I do:
tnoremap <Leader><Esc> <C-w>N
Now I can switch to Normal mode with my Leader key, which I’ve set to the comma, followed by the
I hope you found that useful.