vim repl

警告
本文最后更新于 2023-09-16,文中内容可能已过时。

Vim 环境中运行 REPL 程序。

  • 使用触发键 <Leader>t

  • 对于多个 buffer 的问题,需要改一下绑定键

    1
    2
    
    " handling multi buffer switch:  https://github.com/sillybun/vim-repl/issues/19
    tnoremap <Leader>n <C-w>:bnext<CR>
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Plug 'sillybun/vim-repl', { 'for': ['python', 'r'], 'on':'REPLToggle' }

" Vim-repl -------------------------------------------------------------------
let g:repl_program = {
            \   'python': 'ipython',
            \   'default': 'zsh',
            \   'r': 'R',
            \   'lua': 'lua',
            \   }
let g:repl_width = 120 "REPL windows width"
let g:repl_predefine_python = {
            \   'numpy': 'import numpy as np',
            \   'matplotlib': 'from matplotlib import pyplot as plt'
            \   }
let g:repl_python_auto_import = 1
let g:repl_cursor_down = 1
let g:repl_python_automerge = 1
let g:repl_ipython_version = '7'
let g:repl_auto_sends = ['class ', 'def ', 'for ', 'if ', 'while ', 'with ', 'async def', '@', 'try']
let g:repl_python_auto_send_unfinish_line = 1
let g:repl_cursor_down = 1
let g:repl_python_auto_import = 1
nnoremap <Leader>t :REPLToggle<Cr>
" handling multi buffer switch:  https://github.com/sillybun/vim-repl/issues/19
tnoremap <Leader>n <C-w>:bnext<CR>
tnoremap <Leader>h <C-w><C-h>
tnoremap <Leader>l <C-w><C-l>
"let g:repl_width = None                           "窗口宽度
"let g:repl_height = None                          "窗口高度
" ref: http://stackoverflow.com/questions/598113/can-terminals-detect-shift-enter-or-control-enter
let g:sendtorepl_invoke_key = "<CR>"          "传送代码快捷键,默认为<leader>w
nnoremap <leader>re :REPLSendSession<Cr>
let g:repl_position = 3                             "0表示出现在下方,1表示出现在上方,2在左边,3在右边
let g:repl_stayatrepl_when_open = 0         "打开REPL时是回到原文件(1)还是停留在REPL窗口中(0)"
let g:repl_console_name = 'Vim-REPL'
tnoremap <C-h> <C-w><C-h>
tnoremap <C-j> <C-w><C-j>
tnoremap <C-k> <C-w><C-k>
tnoremap <C-l> <C-w><C-l>

" tnoremap <C-n> <C-w>N
tnoremap <ScrollWheelUp> <C-w>Nk
tnoremap <ScrollWheelDown> <C-w>Nj

相关内容

william 支付宝支付宝
william 微信微信
0%