terminal inside vim, inspired from mattn/vim-terminal
if you like my work, check here for a list of my vim plugins, or buy me a coffee
-
Compared to
Vim8's :terminal
- low dependency, require
+channel
only, easily works on Windows, bothcmd.exe
orCygwin bash
- fallback to
system()
if+channel
not supported
- fallback to
- all keymaps works inside terminal window
- easily to copy command output
- low dependency, require
-
Compared to mattn/vim-terminal
- support NeoVim
- use vim's
:command
complete to input shell commands, should be more friendly to use
- (required)
v:version >= 703
, older version may work, but not tested - (optional)
has('channel')
for async shell run
-
use Vundle or any other plugin manager you like to install
Plugin 'ZSaberLv0/ZFVimJob' " required for job impl Plugin 'ZSaberLv0/ZFVimTerminal' " recommended key map nnoremap <leader>zs :ZFTerminal<space>
-
use
:ZFTerminal [your_cmd]
to run terminal, use<tab>
to complete command or file names- take care of special chars of vim cmdline,
:h cmdline-special
- take care of special chars of vim cmdline,
-
<esc>
to quit input, you may visual select and copy the text inside the terminal window -
use
i/I/a/A/o/O
to start input again -
use
q
to kill and close terminal, we would create new terminal session for next:ZFTerminal
call -
use
x
to hide terminal, we would use existing terminal session for next:ZFTerminal
call -
during editing the shell command, you may also use this keymap
cnoremap :: <c-c>q:k$
to edit the command itself quickly
-
g:ZFVimTerminal_shell
which shell to use, default:
let g:ZFVimTerminal_shell = ''
when empty, we would try to detect a proper one, possible values:
cmd
: for Windowssh
: for Windows Cygwinsh --login
: for others
-
g:ZFVimTerminal_windowConfig
terminal window's config, see Log window for more info
those keymaps would be made by default
nnoremap <buffer> i :<c-u>ZFTerminal<space> nnoremap <buffer> I :<c-u>ZFTerminal<space> nnoremap <buffer> o :<c-u>ZFTerminal<space> nnoremap <buffer> O :<c-u>ZFTerminal<space> nnoremap <buffer> a :<c-u>ZFTerminal<space> nnoremap <buffer> A :<c-u>ZFTerminal<space> nnoremap <buffer> <cr> :<c-u>ZFTerminal<cr> nnoremap <buffer> p :<c-u>ZFTerminal <c-r>" nnoremap <buffer> P :<c-u>ZFTerminal <c-r>" nnoremap <buffer> q :ZFTerminalClose<cr> nnoremap <buffer> x :ZFTerminalHide<cr> nnoremap <buffer> <c-c> :ZFTerminalCtrlC<cr>
you may add your own keymaps by:
autocmd FileType ZFTerminal nnoremap <buffer> q :ZFTerminalClose<cr>
-
g:ZFVimTerminalCompatibleMode
whether run in compatible mode, default: 0
when run in compatible, we use
system()
instead ofjob
to run shell -
g:ZFVimTerminal_autoDetectShellEnd
whether use special tricks to detect shell command end, default:
let g:ZFVimTerminal_autoDetectShellEnd = 1
when on, we use
echo
to output special string to detect whether user input command has end, if any strange things occurred, you may disable this feature -
g:ZFVimTerminal_autoEnterInsert
whether auto enter insert mode after running a command, default:
let g:ZFVimTerminal_autoEnterInsert = 1
-
g:ZFVimTerminal_termEncoding
/g:ZFVimTerminal_termEncodingCompatible
the encoding of your terminal, default:
let g:ZFVimTerminal_termEncoding = 'auto'
when not empty, we would try to convert encoding by
iconv()
to&encoding
, see:h encoding-values
for possible value, see also:h termencoding
use 'auto' to enable auto detect:
- for Windows without
sh
executable, try to detect bychcp
- otherwise,
utf-8
would be used
- for Windows without
-
g:ZFVimTerminal_shellPrefix
/g:ZFVimTerminal_shellPrefixCompatible
shell prefix, can be string or
function()
-
g:ZFVimTerminal_CRFix
how to resolve
\r
, default isclearLine
, posible values:clearLine
: same as default shell, clear current linenewLine
: treat\r
as\n
keep
: do not modify, keep original