What's the deal with Deno? We talk with a major contributor to find out. Listen now.
82

You are supposed to press <C-\><C-n>. See :help terminal-emulator for a mapping suggestion.


57

The answer by @romainl is correct but I wanted to add a bit more info for anyone that may have stumbled on this from google like I did. Directly from the docs we get this note: Terminal mode has its own namespace for mappings, which is accessed with the "t" prefix. It's possible to use terminal mappings to customize interaction with the terminal. For ...


10

A better way which I use (and love these days) to jump between terminal (interactive mode with all alias and path set) and vim is using CTRL+Z in normal mode. Work on terminal, and when done type fg to return back to vim right where I left. CTRL+Z Suspend Vim, like :stop. Works in Normal and in Visual mode. 1. Suspend and resume Like most Unix ...


8

From :h terminal-typing CTRL-W can be used to navigate between windows and other CTRL-W commands, e.g.: CTRL-W CTRL-W move focus to the next window CTRL-W : enter an Ex command


8

In your ~/.vimrc add the line set splitbelow This will cause all splits to happen below (including terminal). To change the height of the terminal (row x col) set termsize=10x0


7

The still somewhat new internal terminal implementation of Vim 8 uses the StatusLineTerm highlighting group for the active window and the StatusLineTermNC highlighting group for the statusline of an inactive window. So you might want to tweak the corresponding highlighting groups like this: :hi StatusLineTerm ctermbg=red ctermfg=black guibg=#ff0000 guifg=...


7

Full restore If you want to restore layout with multiple termina buffers, you must restore other windows and buffers too, so it's in fact a full buffer layout restore, it's usage is not limited to terminal buffers. Three things must be done to achive that: Split windows according to saved layout. We can use result of winlayout() to do this. Load buffer in ...


6

You can replace the current window with a terminal using :terminal ++curwin :ter ++curwin " shorter form You can create a mapping or command for convenience nnoremap \t :terminal ++curwin<cr> command! Terminal terminal ++curwin


6

Exit & close tnoremap <Esc> <C-\><C-n>:q!<CR> In Vim 8, this also works: tnoremap <ESC> <C-w>:q!<CR>


6

From vim/src/eval.c: static void eval_job_process_exit_cb(Process *proc, int status, void *d) { [..] if (data->term && !data->exited) { data->exited = true; char msg[sizeof("\r\n[Process exited ]") + NUMBUFLEN]; snprintf(msg, sizeof msg, "\r\n[Process exited %d]", proc->status); terminal_close(data->...


6

Thanks to Christian Brabandt, :ter ++curwin was the thing that I want.


5

First, your function can be simplified into let bufnr = term_start(&shell, {"hidden": 1}) Second, it's not a problem to have buftype ==# 'terminal' and set nobuflisted together, as these are two different options. So if bufnr call setbufvar(bufnr, "buflisted", 0) endif is very much okay. However, the real question is: why you create a terminal at ...


4

I ran into a similar (the same?) issue on two different installs: NVIM v0.2.0 NVIM v0.3.1 As quanta already mentions this change in behavior might be due to the changes introduced in NVIM v0.2.1. I have a shortcut for running things from within nvim, that splits the window, launches the terminal emulator in the new split view and executes there. After ...


4

You can change the name of any buffer by using the :file {name} command. However, doing so changes that alternate-file to the previous name, which you may not want in this case. The :keepalt command avoids that issue. Putting it all together, this should do what you want keepalt file meaningful


4

This is my solution for closing terminal windows automatically when the terminal process completes with 0 exit status. Using Martin Tournoij's answer as a starting point I did some investigating on how to get the terminal process exit code in a TermClose event handler. You can examine buffer content to parse the [Process exited ?] line that is appended to ...


4

You could overwrite the mapping by a buffer-local mapping. Just map <ESC> to <ESC>: tnoremap <buffer> <ESC> <ESC>


4

One other thing that you can do is use <Ctrl-P> to go to the 'Previous' command. This is also works in bash terminals. You can also do <Ctrl-N> to go to the 'Next' command.


4

Put the following in ~/.config/nvim/init.vim: augroup custom_term autocmd! autocmd TermOpen * setlocal bufhidden=hide augroup END I don't know if it's enough, but it is working for now. Check the part with bufhidden=hide, this makes only the terminal buffer hidden when not loaded on any split/window. I don't know if I have to change any other ...


4

You need to use :tnoremap to map keys in the :terminal window. So if you want that to work in both normal mode of a regular buffer and of terminal windows, you need to add another set of mappings for the terminal: tnoremap <C-J> <C-W><C-J> tnoremap <C-K> <C-W><C-K> tnoremap <C-L> <C-W><C-L> tnoremap <...


4

Neovim's terminal has "a specialty": a mouse click automatically switches it to "Terminal-Normal" mode. (BTW. That's not a case for Vim, so it does not suffer from this issue.) So it won't work from <LeftMouse>, but we can map <LeftRelease> instead: if has('nvim') augroup terminal_setup | au! autocmd TermOpen * nnoremap <buffer&...


3

This should work too: augroup termIgnore autocmd! autocmd TerminalOpen * set nobuflisted augroup END


3

According to vim documentation, there are two ways: CTRL-W N (note it's uppercase N) CTRL-\ CTRL-n 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.


3

Neovim uses its own internal terminal emulator for :term. You can not change that (as far as I know). The thing you can change is the command interpreter/shell that runs in that terminal. See Wikipedia for the difference: Terminal vs Shell. You can start any command (that you have installed) in the terminal if you just specify it as the argument: :...


3

To open a terminal for running command with height 20 you can do :new +resize20 term://command If the terminal is ready created, you either use :resize 20 or 20<c-w>_ for height. :vertical resize 20 or 20<c-w>| for width.


3

Use :belowright: :belowright terminal Or, more succinctly: :bel term This command is a modifier and affects the command run right after it. (Another useful modifier here is :vertical, to split vertically instead.)


3

I assume you aren't literally asking for a --start-terminal flag :) ...but you can specify a command for Vim to run after it starts up using the -c flag. So this should be as easy as vim -c ':term ++curwin' When I run it I am indeed in a terminal window on the shell command line and it's the only window open. Hopefully that covers what you're asking for.


3

Make a buffer active by its number You can combine win_gotoid() & win_findbuf() to accomplish this: :call win_gotoid(get(win_findbuf(g:tn), 0)) But we can do better for terminal like things by improving a few things: Automatically set our variable on TerminalOpen autocmd Provide methods to send text to the terminal Provide a command to jump to the ...


3

I linked a bunch of Bash stuff here. Sorry if that's off the mark but the points made are almost all *nix and shell flavor agnostic. So you are looking to read an environment variable form a shell running in one of Vim's terminal buffers. Unfortunately, such variables are located in the shell process's memory and the internals of a process, including said ...


3

Terminal buffer is special: When the job has finished and no changes were made to the buffer: closing the window will wipe out the buffer. Change buffer type will stop this. Manual After job finished, clear buffer type: setlocal buftype= This also works: setlocal modifiable " make any change, the 1st change will convert terminal buffer to be a normal ...


2

If you are using Tmux, you may have installed some "vim-like" bindings to move around in the window panes which among other things grab the "C-\" before Vim has a chance to use it. If so, remove these from your .tmux.conf and restart tmux: bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" bind-key -T copy-mode-vi C-\ select-pane -l


Only top voted, non community-wiki answers of a minimum length are eligible