From a3cf90c826501a0b47f03c64b106aca88fb1501f Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 2 Mar 2021 18:51:29 -0600 Subject: [PATCH] Add Use The Terminal Inside A Vim Session as a Vim til --- README.md | 3 ++- vim/use-the-terminal-inside-a-vim-session.md | 26 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 vim/use-the-terminal-inside-a-vim-session.md diff --git a/README.md b/README.md index c143a0d..9df00e0 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_1067 TILs and counting..._ +_1068 TILs and counting..._ --- @@ -1216,6 +1216,7 @@ _1067 TILs and counting..._ - [Turning Off Search Highlighting](vim/turning-off-search-highlighting.md) - [Unloading A Buffer](vim/unloading-a-buffer.md) - [Use Active Window With BufExplorer](vim/use-active-window-with-bufexplorer.md) +- [Use The Terminal Inside A Vim Session](vim/use-the-terminal-inside-a-vim-session.md) - [Using vim-surround With A Visual Selection](vim/using-vim-surround-with-a-visual-selection.md) - [Verbose Commits With Fugitive](vim/verbose-commits-with-fugitive.md) - [View Commit History of a File](vim/view-commit-history-of-a-file.md) diff --git a/vim/use-the-terminal-inside-a-vim-session.md b/vim/use-the-terminal-inside-a-vim-session.md new file mode 100644 index 0000000..417ac8a --- /dev/null +++ b/vim/use-the-terminal-inside-a-vim-session.md @@ -0,0 +1,26 @@ +# Use The Terminal Inside A Vim Session + +With [the release of Vim 8.1](https://www.vim.org/vim-8.1-released.php) comes +the ability to open a terminal window _within_ a Vim session. + +The `:terminal` command (or `:term` for short) opens up a buffer window that +looks like a strange mix between any old Vim session and your terminal's shell +prompt. + +Once the `:terminal` window is open, you can hit `i` to switch to +_terminal-mode_. This puts the cursor on the shell prompt so that you can start +executing shell commands. Once in this mode, you most of your keybindings will +be ignored as Vim is providing terminal emulation. + +Once you are done with the terminal, you can type `exit` like you would in any +other shell and it will terminate that process. + +Alternatively, you can hit `Ctrl-\ Ctrl-n` which takes you out of terminal-mode +and back into Normal mode. From here, you can use all the Vim things to +navigate, search, yank, etc. from the terminal output. + +You can also (if `hidden` is set), switch to another buffer. The Vim `:term` +buffer is preserved and you can return to it later, hitting `i` to start +interacting with it again. + +See `:h :term` for more details.