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):
在這裏插入圖片描述

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