4

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


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 <...


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

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.)


2

If you want to paste something into the terminal window, you can use the command CtrlWReg (if you are in terminal job mode). For your macro, that would be something along: qqY<C-W>w<C-W>"0<C-W>wq (provided that the cursor is at the start of the line in the other window. The error message Cannot make changes, 'modifiable' is off happens ...


2

A little experiment: Go to your fresh opened terminal, and do an echo: echo 1 Leave it in terminal job mode, go back to your original window, execute: exec "norm! \<c-w>pggyy\<c-w>pp" You should see a new line in your current buffer, it's copied from first line of terminal buffer. As ggyy are normal mode commands, it tells us that when you ...


2

The problem is that you can't really use :normal in terminal mode, since that mode is special, it doesn't really behave like Normal/Insert mode in a normal vim buffer. Instead, you can use the term_sendkeys() function to send the buffer to the terminal. This should work: :execute "normal yaw\<c-w>j" | call term_sendkeys('', @0) Or: :execute "...


2

I would solve this in bash: 1) Move all setting that you need in login shells and non-login shells to the file .bashrc 2) Add the following to the end of your .bash_profile: # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi You could drop the if..., as the file always exists. Background: The file .bashrc is source ...


2

I'm assuming that by "terminal buffers" you mean the :terminal command. In theory you can just use the ++cols=1000 option or :set termsize (8.0)/set termwinsize (8.1) commands to set a wider terminal width, at the expense of having to scroll to read the whole line. In practice, this new feature seems rather buggy. There are other options, however. Copying ...


2

Thanks to @Matt I now know that if I close the terminal buffer myself instead of having the 'term_finish':'close' argument of term_start() do it, then it doesn't do the weird behavior of sometimes opening a different file. So I've 'term_finish':'close' that with an exit_cb that closes the buffer. Here's what I use in full: function! JW_on_term_exit(a, b) ...


2

Sure—use <C-w>: in your terminal mappings to get a colon command line instead of "escaping" to normal mode: tnoremap <silent> <C-H> <C-W>:call WinTabSwitch('h')<CR>


1

As @statox suggested in comments I should have used tnoremap to implement it. The following works fine: execute "tnoremap ".g:toggle_term ." <C-w>:call ToggleTerminal()<CR>" The mistake I initially made was the space right after the N execute "tnoremap ".g:toggle_term ." <C-w>N :call ToggleTerminal()<CR>" and since I rebound ...


1

The help for the function term_setansicolors provides some more details. The short story is these 16 colors form a conventional palette which terminal programs use when outputting text. You can set them to anything you want, but it's best to stick to the vague color descriptions below. term_setansicolors({buf}, {colors}) *term_setansicolors()* ...


1

You can create a mapping which will close the terminal buffer directly. Then Vim will not open an additional empty buffer and will exit. For simplicity I assume that the terminal is running shell, so Ctrl-D exits it normally. tnoremap <silent><C-D> <C-D><C-\><C-N>ZQ


1

EDIT The problem was actually a bug in neovim fixed by the commit 47b7b471fa which is now merged in master. So after asking the Neovim issue tracker it turns out this is the current "expected" behavior of the code: In terminal.c the function adjust_topline() iterates over FOR_ALL_WINDOWS_IN_TAB, changing that to iterate over FOR_ALL_TAB_WINDOWS fixes my ...


1

In the :terminal, you can put any register using (<c-w> = ctrl w): <c-w>"{register} In particular, to insert the contents of a variable you can use the expression register: <c-w>"= g:variable <cr> If you are writing a script, in vim's terminal you may use the function term_sendkeys to send the contents of a variable to the ...


1

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 ...


1

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.


1

You can use the term_getjob() function to get the Job associated with a terminal. You can then use the job_info() function to query the "process" attribute of the job. let job = term_getjob(5) echo job_info(job).process


1

I tested that this works. It assumes that the terminal is opened in buffer 2. You can check which buffer the terminal is open in with ls. :terminal CTRL-W W :let $VIM_DIR=expand('%:p:h') :call term_sendkeys(2, "cd $VIM_DIR\n") :call term_sendkeys(2, "pwd\n") Also your initial command worked for me. nmap <F12> :let $VIM_DIR=expand('%:p:h')<CR&...


1

This is a documented 'feature' of :tnoremap as tnoremap effectively only work for insert mode style actions and thus any variant using tmap will not work. Adding the below to init.vim will remap the action of Ctrl-w + s in normal mode only for the terminal buffer autocmd BufWinEnter,WinEnter term://* nnoremap <buffer> <C-w>s <C-\><C-n&...


1

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.


1

I can't comment, only post an answer, but I'd like to say that the augroup MyTermMappings autocmd! autocmd TermOpen * nnoremap <buffer> q a augroup END works but it must go in your init.vim file and not your standard .vimrc if you use vi/m at all. Putting it into the .vimrc file causes a No such group or event: TermOpen * nnoremap <buffer> ...


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