作为一个坚定的VIM倡导者和R用户,我已经开始真正享受VIM -R-plugin中VIM -tmux的相互作用。我一直找不到这个的python版本。不存在吗?
我注意到一个类似的问题,它显示了Python的Rstudio等价,但我正在寻找这样的东西,生活在vim....
编辑: 特别是,我正在寻找的东西
- 有语法高亮显示
- 有代码完成
- 将允许我将代码从vim选项卡发送到python REPL
加分如果:
- 它有一个对象浏览器(检查我的会话变量)
- 在vim选项卡中打开文档
另一种方法是使用screen
vim插件。我更喜欢这个,因为它避免了配置步骤。下面是你要做的:
- 安装
screen
vim插件 - 在你的
.vimrc
中创建一些方便的命令(见我在下面添加的) 打开
.py
文件,点击<LocalLeader>p
,你就可以走了。请注意,在打开.py
文件之前,您不必打开TMUX
。这是我添加的(基于https://github.com/akhilsbehl/configs/blob/master/vimrc):
)" use tmux for splitting screen
let g:ScreenImpl = "Tmux"
" default width of tmux shell pane
let g:ScreenShellWidth = 82
" open an ipython shell (! for vertical split)
autocmd FileType python map <LocalLeader>p IPython!<CR>
" close whichever shell is running
autocmd FileType python map <LocalLeader>q :ScreenQuit<CR>
" send commands
" line
autocmd FileType python map <LocalLeader>r V:ScreenSend<CR>0j
" block
autocmd FileType python map <LocalLeader>b {jv}:ScreenSend<CR>}
" selection
autocmd FileType python map <LocalLeader>v :ScreenSend<CR>`>}0j
" convenience
autocmd FileType python map <LocalLeader>gw :call g:ScreenShellSend('!pwd')<CR>
autocmd FileType python map <LocalLeader>L :call g:ScreenShellSend('!clear')<CR>
autocmd FileType python map <LocalLeader>t :call g:ScreenShellSend('%%time')<CR>
autocmd FileType python map <LocalLeader>tt :call g:ScreenShellSend('%%timeit')<CR>
autocmd FileType python map <LocalLeader>db :call g:ScreenShellSend('%%debug')<CR>
autocmd FileType python map <LocalLeader>pr :call g:ScreenShellSend('%%prun')<CR>
" get ipython help for word under cursor
function GetHelp()
let w = expand("<cword>") . "??"
:call g:ScreenShellSend(w)
endfunction
autocmd FileType python map <LocalLeader>h :call GetHelp()<CR>
" get `dir` help for word under cursor
function GetDir()
let w = "dir(" . expand("<cword>") . ")"
:call g:ScreenShellSend(w)
endfunction
autocmd FileType python map <LocalLeader>d :call GetDir()<CR>
" get `len` for word under cursor
function GetLen()
let w = "len(" . expand("<cword>") . ")"
:call g:ScreenShellSend(w)
endfunction
autocmd FileType python map <LocalLeader>l :call GetLen()<CR>
我知道它不像你希望的那样功能齐全,但是我刚刚发布了这个插件。
https://github.com/iago-lito/intim- 它封装了sbstn 提供的tmux会话
- 它还提供语法高亮
- 在vim缓冲区中的帮助
- 没有检查python对象,但是"热键"可以使它非常快速地发送有关自定义python项目的请求。
尝试一下,不要犹豫,在repo上提交你的第一个bug报告/特性请求:)
目前为止我找到的最好的是https://github.com/jpalardy/vim-slime
如何使用vim-slime
:
- Start
tmux
- 拆分为两个窗格
- 在一个窗格中打开
vim
脚本 - 切换到其他窗格
- 使用
echo $TMUX_PANE
获取tmux窗格的名称(需要7) - 打开
ipython
- 在
vim
中运行:SlimeConfig
,保留套接字名称"default"
并输入目标窗格,例如%14
- 使用C-c -c将代码从
vim
发送到ipython