Home

Awesome

I require a cutting tool

About

Vim-terminator runs your current file. Out of the box it comes with support for 47 languages and can be extended for any vim file type. Using automatic file type detection, this plugin can

  1. Run your current file (or visual selection) in a custom "output buffer"
  1. Run your current file (or visual selection) in a vim terminal
  1. Start a REPL using the current file type
  2. Send parts of the current buffer to a terminal. This includes

Demo

Run the current file in the output buffer:

Run current file in output buffer

Run the current file containing errors for quick fixing:

Run current file with errors

Run the current file in a terminal:

Run current file in a neovim terminal

Send text between delimiters to a REPL:

Send text in delimiter to a new REPL

Automatic window resizing

Automatic window resizing

Installation

If you use vim-plug

plug 'erietz/vim-terminator', { 'branch': 'main'}

If you use packer

use 'erietz/vim-terminator'

Note: This plugin requires neovim or vim version >= 8.0

Usage

Key mapDescription
<leader>otOpens (or reopens) a terminal window
<leader>orOpens a repl
<leader>rfRuns your current file (or visual selection) in the output buffer
<leader>rtRuns your current file (or visual selection) in the terminal
<leader>rsStops the running job in the output buffer
<leader>rmModifies command via command line before running in output buffer
Pro tip: hit <c-f> on vims command line to further modify before running
<leader>sdSend text in delimiter to terminal
<leader>ssSends visual selection to terminal
:TerminatorSendToTerminal echo "hi there"Sends echo "hi there" to the terminal

"I do not like these key bindings, I'd like to set my own"

Extensibility

let g:terminator_runfile_map = {
            \ "javascript": "node",
            \ "python": "python -u",
            \ "c": "gcc $dir$fileName -o $dir$fileNameWithoutExt && $dir$fileNameWithoutExt",
            \ "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
            \ }

allowing use of the variables defined below

Variable nameDescription
$fileNamewhat you would get from running basename on the file
$fileNameWithoutExtsame as $fileName with everything after and including the last . removed
$dirthe full path of the parent directory of the filename
$dirWithoutTrailingSlashsame as $dir with the trailing slash removed
let g:terminator_repl_command = {
  \'python' : 'ipython --no-autoindent',
  \'javascript': 'node',
  \}

REPL delimiters

Managing window splits

Two variables can be set to help manage how windows are split. A combination of these variables can go a long way.

  1. let g:terminator_split_fraction = <decimal> where <decimal> is a number between 0 and 1.
  2. let g:terminator_split_location = '<option>' where <option> is something like

There is also the option let g:terminator_auto_shrink_output = 1 which automatically shrinks the output buffer (in a horizontal split) to the size of the output if it is less than the maximum split size given by g:terminator_split_fraction.

FAQ

The quickfix window is populated but I can't jump to the errors

Set the :compiler for the file type. This in turn sets errorformat. See :h errorformat

The quickfix window is not catching errors after running code of a different file type

Switch to the output buffer and run :bdelete. Then run your code again.