1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-02 22:58:01 +00:00

Add Escaping Terminal Mode In An Nvim Termianl as a vim til

This commit is contained in:
jbranchaud
2018-02-22 13:15:16 -06:00
parent 3b32b09c89
commit fa699348a8
2 changed files with 29 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
For a steady stream of TILs from a variety of rocketeers, checkout
[til.hashrocket.com](https://til.hashrocket.com/).
_623 TILs and counting..._
_624 TILs and counting..._
---
@@ -641,6 +641,7 @@ _623 TILs and counting..._
- [Display Word Count Stats](vim/display-word-count-stats.md)
- [Edges Of The Selection](vim/edges-of-the-selection.md)
- [End Of The Word](vim/end-of-the-word.md)
- [Escaping Terminal-Mode In An Nvim Terminal](vim/escaping-terminal-mode-in-an-nvim-terminal.md)
- [Filter Lines Through An External Program](vim/filter-lines-through-an-external-program.md)
- [Fix The Spelling Of A Word](vim/fix-the-spelling-of-a-word.md)
- [Fold A Visual Selection And Expand It Back](vim/fold-a-visual-selection-and-expand-it-back.md)

View File

@@ -0,0 +1,27 @@
# Escaping Terminal-Mode In An Nvim Terminal
A recent
[TIL](https://til.hashrocket.com/posts/iity78ly38-open-a-zsh-terminal-in-a-split-window-in-neovim)
by Chris Erin showed how to split open a terminal in a
[Neovim](https://neovim.io/) session -- `:sp term://zsh`.
The terminal is emulated into a Vim buffer which means that you can treat it
sort of like any other Vim buffer. You start in Normal mode. Once you use
any mapping that would transition you into Insert mode, you'll instead find
yourself in _Terminal_ mode. Terminal mode works just like any `zsh`
session (give `ls` a try).
Try hitting `<Esc>` though and you'll see that you stay in Terminal mode
instead of being transitioned back to Normal mode.
So how do you get back to Normal mode?
Hit `<Ctrl-\><Ctrl-n>`.
This is a pretty awkward key mapping though, so follow [the Nvim Terminal
docs](https://neovim.io/doc/user/nvim_terminal_emulator.html) and bring back
the Escape key.
```vimscript
:tnoremap <Esc> <C-\><C-n>
```