erietz / vim-terminator

:dagger: Run your code in an output buffer or a vim terminal conveniently
GNU General Public License v3.0
116 stars 2 forks source link

Make terminal the active buffer whenever it opens? #7

Closed jakobkhansen closed 3 years ago

jakobkhansen commented 3 years ago

I often want to scroll in the terminal or run another command in the terminal after I open it with this, is it possible to make the terminal the active buffer whenever I run a terminator command which opens a terminal?

erietz commented 3 years ago

I am not sure I understand your questions entirely. When this plugin opens a terminal, you should be able to switch to it by using window commands. For example, CTRL-W j should allow you to switch from the current buffer to the terminal, assuming that the terminal is below your current buffer. Then if the cursor is in the terminal buffer, you can go into insert mode by pressing i or a and go back to normal mode by pressing CTRL-\ CTRL-n. Is this what you are asking?

jakobkhansen commented 3 years ago

No, this is not what I meant. I want my cursor to automatically go to the terminal buffer window whenever I do a terminator command which opens the terminal. This is how :sp term://bash works for me by default, automatically moving to that window whenever I open it.

erietz commented 3 years ago

Oh, I see. I suppose I could create an option (something like let g:terminator_focus_terminal_always = 1) to always focus on the terminal whenever text is sent to it.

erietz commented 3 years ago

I thought of an easier solution. I have updated the file plugin/terminator.vim so that every mapping that is provided by the plugin has a corresponding vim command. This allows you to make whatever mappings you like. To get your desired functionality, you could use something like this:

nnoremap <silent> <leader>rt :TerminatorRunFileInTerminal<CR>:wincmd p<CR>i<CR>

The wincmd p will put the cursor back on the previous window (which is the terminal). The i will put you in insert mode which is necessary in neovim but not necessary in normal vim.

jakobkhansen commented 3 years ago

Thanks!