vim8.1 内置终端分屏新特性(Vim inner shell of split window)

vim8.1 终端分屏新特性

Vim inner shell of split window

先说下怎么升级8.1 mac 用户
how to update to 8.1 with mac user

brew install vim --with-lua --with-override-system-vi (命令行版)
brew install macvim --with-lua --with-override-system-vim (gui版)

如果之前用过brew装过vim,执行这个命令
if you use brew before, use this command to update

brew upgrade vim/macvim

vim 8.1增加了一个新的特性,就是分屏bash啦,先看下效果图

new feature of vim8 inner shell

bash图
CN:
就是酱了,反正就是有点类似Neovim的分屏bash效果,又或者是tmux做的分屏效果,废话不多说,接下来直接说怎么用。
在底层命令行模式直接输入: term bash就完成了一次终端分屏(zsh党友情提示 term zsh也行哦)。
简单提下怎么关闭和窗口切换:

EN:
term bash or term zsh

shortchut:
关闭(close) ctrl+w+q
切换(jump window) ctrl+w+h/j/k/l

2019年06月11日更新

updated at 20190611

CN:
term ipython可以直接开出python的pecl交互分屏,另外注意两个分屏之间是可以通过流传递数据来联动的,比如可以在”代码分屏“做vim块选择,然后直接输出到 ipython的pecl控制台编译显示。
核心vimrc代码如下:
EN:
term ipython can open python’s pecl console directly, make attention that two split window can exchange data(code) if you use vim block select and config some shortcut (↓) in vimrc so that ipython can show the result fluently.

"这样选中你要运行的代码<leader>te 就会发到python shell里
"your runing code could send to python shell

nnoremap <leader>te V:call SendToTerminal()<CR>$
vnoremap <leader>te <Esc>:call SendToTerminal()<CR>
function! SendToTerminal()
    let buff_n = term_list()
    if len(buff_n) > 0
        let buff_n = buff_n[0] " sends to most recently opened terminal
        let lines = getline(getpos("'<")[1], getpos("'>")[1])
        let indent = match(lines[0], '[^ \t]') " check for removing unnecessary indent
        for l in lines
            let new_indent = match(l, '[^ \t]')
            if new_indent == 0
                call term_sendkeys(buff_n, l. "\<CR>")
            else
                call term_sendkeys(buff_n, l[indent:]. "\<CR>")
            endif
            sleep 10m
        endfor
    endif
endfunction

举个栗子(example):
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章