Skip to content

Instantly share code, notes, and snippets.

@dantonnoriega
Last active October 28, 2021 06:58
Show Gist options
  • Save dantonnoriega/2dd797176717450edd4c949621f9b794 to your computer and use it in GitHub Desktop.
Save dantonnoriega/2dd797176717450edd4c949621f9b794 to your computer and use it in GitHub Desktop.
Step by step instruction to set up a VIM REPL with TMUX on a linux box. I found most instruction onlin convoluted and confusing.

Set up tmux with a vim REPL on a linux box

  1. install https://github.com/tpope/vim-pathogen into ~/.vim/
  2. install https://github.com/jpalardy/vim-slime into ~/.vim/bundle
  3. copied default vimrc to a user copy: cp /etc/vimrc ~/.vim/vimrc
  4. added the following to the end of ~/.vim/vimrc
" vim slime
let g:slime_python_ipython = 1

let g:slime_target = "tmux"
let g:slime_paste_file = "$HOME/.slime_paste"

" Pathogen load
filetype off

call pathogen#infect()
call pathogen#helptags()

filetype plugin indent on
  1. Open a new tmux session with name "default"
tmux new -s default
  1. Create a new (vertical) pane. Panes are referenced by [window num].[pane num]. In a new tmux session, the first window and pane is 0.0. The second will be 0.1. If I create a new window and pane, it will be assigned 1.0.
  2. Let's assume I stay in window 0 and create a new pane 0.1. In pane 0.1, start up desired program e.g. using ipython on a linux box e.g.
export PATH=~/anaconda3/bin:$PATH
ipython --colors=Linux --no-confirm-exit --pylab=agg
  1. One preps a fresh vim session to send to the REPL pane by hitting < ctrl-c, ctrl-c >. For example, assume in original pane 0.0 I open a script using vim to send to REPL pane 0.1. Hitting < ctrl-c, ctrl-c > in vim pane 0.0 initiates a prompt at the bottom of vim to name the session (default) and the target pane (0.1). That is, if coding with vim in pane 0.0 with the intention to send code to pane 0.1, I would see the following at the bottom of my vim session:
tmux socket name or absolute path: default 
tmux target pane: 0.1
  1. From now until the vim session is close (:wq), hitting < ctrl-c, ctrl-c > will send the current BLOCK (not line) of code. Again, BLOCK of code, NOT LINE of code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment