【问题标题】:A python plugin for vim like vim-r-pluginvim 的 python 插件,如 vim-r-plugin
【发布时间】:2017-10-21 20:59:49
【问题描述】:

作为坚定的 VIM 倡导者和 R 用户,我已经成长为真正享受 Vim-R-plugin 中的 vim-tmux 相互作用。我一直很难找到这个的 python 版本。不存在吗?

我注意到一个类似的问题,它显示了Rstudio equivalents for Python,但我正在寻找类似的东西,生活在 vim 中....

编辑:特别是,我正在寻找的东西

  • 有语法高亮
  • 有代码完成
  • 将允许我将代码从 vim 选项卡发送到 python REPL

奖励积分如果:

  • 它有一个对象浏览器(用来检查我的会话变量的东西)
  • 在 vim 选项卡中打开文档

【问题讨论】:

  • 您需要更具体地说明您要查找的内容。尽管如此,Jedi 和 Python 模式的结合还是非常有用的。这是我主要用于 Python 开发的 Vimrc:github.com/WoLpH/dotfiles/blob/master/_vimrc
  • python模式是否允许REPL交互?
  • 您找到解决方案了吗?我正在使用 vimux,但它只完成了部分工作。

标签: python vim ide vim-plugin


【解决方案1】:

另一种方法是使用screen vim 插件。我更喜欢这样,因为它避免了配置步骤。所以这就是你要做的:

  1. 安装screen vim 插件
  2. 在您的 .vimrc 中创建一些方便的命令(请参阅我在下面添加的内容)
  3. 打开.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>

【讨论】:

    【解决方案2】:

    我确信它没有你想要的那么全功能,但我刚刚发布了这个插件。

    https://github.com/iago-lito/intim

    • 它包含 sbstn 提供的 tmux 会话
    • 它还提供语法高亮显示
    • 在 vim 缓冲区中的帮助
    • 没有检查 python 对象,但是“热键”可以非常快速地发送有关您的自定义 python 项目的请求。

    尝试一下,不要犹豫,在 repo 上提交您的第一个错误报告/功能请求:)

    【讨论】:

    • 我一直在寻找那个 loon looong 时间,所以试试你的 :)
    • @SimonC。别客气。请不要犹豫提供反馈,因为我们的用户还很少:)
    【解决方案3】:

    目前我发现的最好的是https://github.com/jpalardy/vim-slime

    如何使用vim-slime

    1. 开始tmux
    2. 分成两个窗格
    3. 在一个窗格中使用vim 打开脚本
    4. 切换到其他窗格
    5. 使用echo $TMUX_PANE 获取tmux 窗格的名称(7 需要)
    6. 打开ipython
    7. vim中运行:SlimeConfig,保持套接字名称"default"并进入目标窗格,例如%14
    8. 使用 C-c C-c 将代码从vim 发送到ipython

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多