I like to use two very nice extensions that help make vim a powerful IDE by enabling interactive programming and streamlined syntax checking.


The first one is a plugin called vim-slime. It allows text within vim to be piped to the input of another tmux shell window (it’s also compatible with other vim windows, screen, and other terminals). The idea stems from an old emacs plugin for the lisp programming language called SLIME, but I think it’s true power is unleashed in vim where it can be used with any REPL-style programming language. This is really nice for interactive programming between multiplexed terminal windows. It’s very simple to install thanks to the new pack feature included in vim 8:


mkdir -p $HOME/.vim/pack/plugins/start && cd $HOME/.vim/pack/plugins/start && git clone git://github.com/jpalardy/vim-slime.git


To make it work with tmux by default and use a temp file as a buffer, I also include in my .vimrc

let g:slime_target = "tmux"
let g:slime_paste_file = "/tmp/.slime_paste"


Using this function enables pressing Ctrl-C  twice to send the current paragraph to the specified tmux window. On the first instance it will prompt for a tmux window to slime the output to. If you use a configuration like mine in which your code is in a split pane above your interactive shell, “1.1” should be input at the prompt to signify window #1 and pane #1.



The second one is a syntax checking function bound to F4. This works by creating a function in the ~/.vimrc config file to show output from the command line in a new vim window.

Originally adapted from script on the vim wiki:


function! s:RunShellCommand(cmdline)
   " vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window
   let expanded_cmdline = a:cmdline
   for part in split(a:cmdline, ' ')
      if part[0] =~ '\v[%#<]'
         let expanded_part = fnameescape(expand(part))
         let expanded_cmdline = substitute(expanded_cmdline, part, expanded_part, '')
      endif
   endfor
   let out = system(expanded_cmdline)
   echo out
   return out
endfunction

command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)

I also create a function using the new :Shell command allowing syntax checking for some of my favourite languages. check_syntax() is then mapped to F4 in normal mode


function! s:check_syntax()
   " Bound to F4
   " % char represents name of file under cursor
   exec 'w' 
   if &filetype == 'python'
      exec "Shell python -m py_compile %"
   elseif &filetype == 'php'
      exec "Shell php -l %"
   elseif &filetype == 'sh'
      exec "Shell bash -n %"
   elseif &filetype == 'c'
      exec "Shell make target"
   elseif &filetype == 'cpp'
      exec "Shell make target"
   endif
endfunction

nnoremap <F4> :call <SID>check_syntax()<CR>

Alternatively, :Shell can be called directly from within vim to display any output from the command line


:Shell ls -l

Interactive Python in Vim by pressing Ctrl-C twice


Python Syntax Checking with F4