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
+channelonly, easily works on Windows, bothcmd.exeorCygwin bash- fallback to
system()if+channelnot 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
:commandcomplete 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/Oto start input again -
use
qto kill and close terminal, we would create new terminal session for next:ZFTerminalcall -
use
xto hide terminal, we would use existing terminal session for next:ZFTerminalcall -
during editing the shell command, you may also use this keymap
cnoremap :: <c-c>q:k$to edit the command itself quickly
-
g:ZFVimTerminal_shellwhich 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_windowConfigterminal 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:ZFVimTerminalCompatibleModewhether run in compatible mode, default: 0
when run in compatible, we use
system()instead ofjobto run shell -
g:ZFVimTerminal_autoDetectShellEndwhether use special tricks to detect shell command end, default:
let g:ZFVimTerminal_autoDetectShellEnd = 1when on, we use
echoto output special string to detect whether user input command has end, if any strange things occurred, you may disable this feature -
g:ZFVimTerminal_autoEnterInsertwhether auto enter insert mode after running a command, default:
let g:ZFVimTerminal_autoEnterInsert = 1 -
g:ZFVimTerminal_termEncoding/g:ZFVimTerminal_termEncodingCompatiblethe 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-valuesfor possible value, see also:h termencodinguse 'auto' to enable auto detect:
- for Windows without
shexecutable, try to detect bychcp - otherwise,
utf-8would be used
- for Windows without
-
g:ZFVimTerminal_shellPrefix/g:ZFVimTerminal_shellPrefixCompatibleshell prefix, can be string or
function() -
g:ZFVimTerminal_CRFixhow to resolve
\r, default isclearLine, posible values:clearLine: same as default shell, clear current linenewLine: treat\ras\nkeep: do not modify, keep original
