Repl in vim

When working with Julia, it can be convenient to use a REPL (Read-Eval-Print Loop) within the Vim text editor. This allows you to write and execute Julia code directly within Vim, without needing to switch to a separate terminal window. In this article, we will explore three different ways to set up a Julia REPL within Vim, each with its own advantages and disadvantages.

Option 1: Using the Julia-Vim plugin

The Julia-Vim plugin is a popular choice for integrating Julia with Vim. It provides features such as syntax highlighting, code completion, and the ability to send code directly to a Julia REPL. To set up the Julia-Vim plugin, follow these steps:


# Install the Julia-Vim plugin
$ git clone https://github.com/JuliaEditorSupport/julia-vim.git ~/.vim/pack/julia/start/julia-vim

# Add the following lines to your .vimrc file
filetype off
set rtp+=~/.vim/pack/julia/start/julia-vim
filetype plugin indent on

After setting up the Julia-Vim plugin, you can open a Julia file in Vim and start a Julia REPL by running the command :JuliaREPL. This will open a new split window within Vim, where you can interact with the Julia REPL.

Option 2: Using the Conque-Shell plugin

If you prefer a more flexible solution, you can use the Conque-Shell plugin to run a Julia REPL within Vim. This allows you to run any shell command within Vim, including starting a Julia REPL. Here’s how to set it up:


# Install the Conque-Shell plugin
$ git clone https://github.com/vim-scripts/Conque-Shell.git ~/.vim/bundle/Conque-Shell

# Add the following lines to your .vimrc file
let g:ConqueTerm_DefaultOptions = '--nomenubar'
let g:ConqueTerm_CloseOnExit = 1

Once the Conque-Shell plugin is installed, you can open a Julia file in Vim and start a Julia REPL by running the command :ConqueTerm julia. This will open a new split window within Vim, where you can interact with the Julia REPL.

Option 3: Using the terminal emulator within Vim

If you prefer a more lightweight solution, you can use the built-in terminal emulator within Vim to run a Julia REPL. This allows you to run any shell command within Vim, including starting a Julia REPL. Here’s how to do it:


# Add the following lines to your .vimrc file
set splitbelow
set splitright
terminal julia

After adding these lines to your .vimrc file, you can open a Julia file in Vim and start a Julia REPL by running the command :terminal. This will open a new split window within Vim, where you can interact with the Julia REPL.

Of the three options, the Julia-Vim plugin provides the most comprehensive integration with Vim. It offers features such as syntax highlighting and code completion, making it easier to write and navigate Julia code. However, it requires additional setup steps and may be more resource-intensive compared to the other options. If you prefer a simpler setup or have limited system resources, the Conque-Shell plugin or the terminal emulator within Vim are viable alternatives.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents