{"slug": "lisp-in-vim-2019", "title": "Lisp in Vim (2019)", "summary": "The article discusses the development of Lisp programming support in the Vim text editor, focusing on two plugins: Slimv and Vlime. Slimv has been available for over a decade, while Vlime is a newer plugin less than three years old, and both enable interactive Lisp development within Vim. The author provides a comparison of the two plugins, covering their features, setup, and usage, but notes the article is not a full tutorial.", "body_md": "# Lisp in Vim\n\n**Susam Pal** on 07 Dec 2019\n\n## Introduction\n\nFifteen years ago, writing Lisp code in Vim was an odd adventure.\nThere were no good plugins for Vim that assisted in structured\nediting of Lisp s-expressions or allowed interactive programming by\nembedding a Lisp Read-Eval-Print-Loop (REPL) or a debugger within\nthe editor. The situation has improved a lot since then. In the\nlast ten years, we have seen active development of two Vim plugins\nnamed [Slimv](https://github.com/kovisoft/slimv) and\n[Vlime](https://github.com/l04m33/vlime). Slimv is over\n10 years old now. Vlime is more recent and less than 3 years old\nright now. Both support interactive programming in Lisp.\n\nI am going to discuss and compare both Slimv and Vlime in this\narticle. I will show how to get started with both plugins and\nintroduce some of their basic features. I will not cover everything\nthough. This is not a tutorial. For tutorials, see\nthe [ References](#references) section.\n\nIf you are looking only for a comparison of the two plugins or a\nquick recommendation, jump directly to the\n[ Comparison of Slimv and Vlime](#comparison-of-slimv-and-vlime)\nsection or the\n\n[section.](#quick-recommendation)\n\n*Quick Recommendation*## Contents\n\n[Introduction](#introduction)[Background](#background)[Vim Plugin Management](#vim-plugin-management)[Software Versions](#software-versions)[Get Started](#get-started)[Use Debugger and Inspector](#use-debugger-and-inspector)[Trace Function](#trace-function)[Nifty Features](#nifty-features)[Other Common Lisp Implementations](#other-common-lisp-implementations)[Other Lisp Dialects](#other-lisp-dialects)[Comparison of Slimv and Vlime](#comparison-of-slimv-and-vlime)[Quick Recommendation](#quick-recommendation)[Disclosure](#disclosure)[References](#references)\n\n## Background\n\nBefore we get started with Slimv and Vlime, it would be nice to take a brief look at the heritage behind these plugins. These plugins provide Lisp development environments for Vim, so their story begins with Lisp.\n\n### Lisp\n\nLisp is a family of programming languages with a distinctive, fully parenthesised prefix notation. It is quite unlike most of the other popular programming languages today like C, Python, Ruby, etc. Its homoiconic nature and its powerful macro system that can transform arbitrary Lisp expressions make it such a flexible, versatile, extensible and introspective language that articles describing Lisp often have the word \"enlightenment\" in them. For example, see the following articles:\n\n-\n(by Paul Graham)*Beating the Averages* -\n(by Slava Akhmechet)*The Nature of Lisp* -\n(by Sinclair Target)*How Lisp Became God's Own Programming Language*\n\nLisp has been described in various ways by various eminent personalities in the history of computing. Alan Kay has famously described Lisp as:\n\nThe greatest single programming language ever designed.\n\nJohn Foderaro has written this about Lisp:\n\nLisp is a programmable programming language.\n\nEric S. Raymond has expressed the enlightenment one experiences by\nlearning Lisp in his famous article titled\n[ How To Become A Hacker](http://www.catb.org/~esr/faqs/hacker-howto.html):\n\nLisp is worth learning for the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.\n\nRandall Munroe, the creator of the\n[XKCD](https://xkcd.com/) webcomic has dedicated two\ncomic strips to Lisp:\n\nDeveloped in 1958 by John McCarthy, Lisp is the second oldest programming language in use today. Only Fortran is older, by one year. Some of the popular Lisp dialects today include Common Lisp, Scheme and Clojure. Most of this article would focus on Common Lisp. Scheme and Clojure would be discussed briefly towards the end of this article.\n\n### Emacs: SLIME\n\nMany Lisp programmers immediately think of Emacs when they think of writing Lisp code. Emacs is a family of text editors. An Emacs editor itself is typically implemented in a dialect of Lisp. There is an Emacs mode named SLIME that provides excellent support for programming in Lisp. SLIME stands for Superior Lisp Interaction Mode for Emacs. First released in August 2003, SLIME was created by Eric Marsden and then later developed further by Luke Gorrie and Helmut Eller. It offers a Read-Eval-Print-Loop (REPL), integrated debugging and interactive evaluation of expressions, all available right within the editor. There are several nifty key bindings available to compile and evaluate parts or whole of the code in the current buffer.\n\nSLIME works by launching a Swank TCP server. Swank is a backend server program written in Common Lisp that listens on a socket to receive SLIME commands from Emacs and execute them. SLIME is so useful that it is considered to be indispensible by many Lisp programmers who write Lisp code in Emacs.\n\n### Vim: Slimv/Vlime\n\nIs there anything similar to SLIME for Vim? Yes, there are two popular options:\n\n-\n**Slimv:** It stands for Superior Lisp Interaction Mode for Vim. It is a Vim plugin created by Tamas Kovacs that was first released in January 2009. -\n**Vlime:** It is a Vim plugin created by Kay Z that was first released in May 2017. It is much more recent than Slimv. Vlime is younger than Slimv by eight years.\n\nBoth plugins use a client-server architecture like SLIME does in Emacs. Both plugins rely on Swank server to be started. In fact, Slimv bundles a slightly modified version of Swank with it, so that it can launch it and connect to it to send expressions to be evaluated. Vlime does not bundle Swank server with itself but it provides a wrapper that automatically downloads Swank server when needed.\n\n## Vim Plugin Management\n\nWhen I started using Vim fifteen years ago, we used to just download\na Vim plugin and copy/extract it to `~/.vim`\n\ndirectory.\nThese days, there are a few plugin management tools for Vim such\nas [Pathogen](https://github.com/tpope/vim-pathogen),\n[Vundle](https://github.com/VundleVim/Vundle.Vim),\n[vim-plug](https://github.com/junegunn/vim-plug), etc. I\nam not going to use any of them because I don't know which one of\nthem you use and I don't want to write down steps for each one of\nthem.\n\nIn fact, I have never used any Vim plugin manager myself. Until Vim\n7, I used to create a `~/.vim/bundle`\n\ndirectory, then\ncopy each plugin to its own directory within it and add the plugin's\ndirectory path to Vim's `runtimepath`\n\noption.\n\nVim 8 has native support for packages which makes installing plugins\nand loading them simpler. With Vim 8, we can copy each plugin to\nits own directory within `~/.vim/pack/plugins/start`\n\nand\nthey are loaded automatically when Vim starts. The directory name\n`plugins`\n\nin this path is only an example. It could be\nany arbitrary name and Vim would still load the plugins fine.\n\nIn this article, I will use Vim 8's native support for packages to\nset up Vim plugins. The only exception to this would be installing\nVlime. The top-level directory of Vlime is not the plugin\ndirectory. The plugin directory is contained in a subdirectory\nnamed `vim`\n\n. This does not conform to the directory\nstructure of plugins in a Vim package. Therefore, in this article,\nI will set up Vlime in the old fashioned way by copying it\nto `~/.vim/bundle`\n\nand then adding the path to its plugin\ndirectory to Vim's `runtimepath`\n\noption.\n\n## Software Versions\n\nSince this article involves several layers of software, some of what is written here may not hold good in future as these various pieces of software change and evolve over time. Therefore, in this section, I will note down the versions of various software tools I used while writing this article. Here they are:\n\n- Debian GNU/Linux 10.1 (buster)\n- Vim 8.1\n-\nSlimv (Git repo last updated on 30 Nov 2019 with commit\n[47a0070](https://github.com/kovisoft/slimv/commits/47a0070)) -\nVlime (Git repo last updated on 16 Oct 2017 with commit\n[065b95f](https://github.com/l04m33/vlime/commits/065b95f)) -\nParedit (Git repo last updated on 30 Nov 2019 with commit\n[d99905a](https://github.com/kovisoft/paredit/commits/d99905a)) -\nRainbow Parentheses (Git repo last updated on 29 Oct 2015 with commit\n[27e7cd7](https://github.com/junegunn/rainbow_parentheses.vim/commits/27e7cd7)) - SBCL 1.4.16.debian\n- GNU CLISP 2.49.92\n- ECL 16.1.3\n- MIT/GNU Scheme 9.1.1 on Debian GNU/Linux 9.11 (stretch)\n- Clojure 1.10.1\n- Quicklisp beta (libraries last updated on 30 Nov 2019)\n- tmux 2.8\n\nYou will probably need only a tiny subset of the tools above depending on which sections in this article you would follow. Just pick the sections you want to try out and follow the steps written in them. They will walk you through the procedure to install the tools applicable to the sections you have picked. Regardless of which sections you pick, I recommend that you definitely go through the three \"Get Started\" subsections below. These subsections go into detail about some of the prerequisites such as support for tmux, Paredit, support for Python interface in Vim, etc. that are not covered in the other sections.\n\nThe choice of Debian may look like an odd one. I want the commands and steps discussed in this article to be easily reproducible in a free and open source operating system. Debian happens to be my favourite. What works on Debian is easily reproducible on Ubuntu and other derivatives, often without any changes to the steps. I believe, it will not be too difficult to translate the steps provided for Debian to the steps that would work on another operating system.\n\nNote that Quicklisp (a prerequisite for Vlime) is still beta\nsoftware at the time of writing this article. The actual steps to\ninstall Quicklisp may change in future. Check\n[https://www.quicklisp.org/](https://www.quicklisp.org/)\nfor the most up-to-date instructions to install Quicklisp.\n\n## Get Started\n\n### Get Started with Slimv and SBCL\n\nHere are the steps to set up Slimv and use it:\n\n-\nInstall the tools required to set up a Common Lisp development environment with Slimv with this command:\n\n```\nsudo apt-get install vim-nox sbcl tmux git\n```\n\nThe default Vim in Debian is\n\n`vim.basic`\n\nprovided by the`vim`\n\npackage which does not have support for Python interface. Slimv is written in Vim script, Lisp and Python 3, so it does need a Vim package that has support for Python interface. One such package is`vim-nox`\n\nthat provides the`vim.nox`\n\ncommand. Installing it automatically updates the`vim`\n\ncommand to run`vim.nox`\n\n. Another such package is`vim-gtk`\n\nwhich additionally provides GUI support. The graphical Vim known as GVim can be launched with the`gvim`\n\ncommand. It runs in the desktop environment. For the purpose of this article, I will stick to`vim-nox`\n\nbecause it is lightweight. All steps meant for Slimv would run equally well on`vim-gtk`\n\n, MacVim and GVim.Installing tmux is optional. Slimv can launch Swank server automatically if Vim is running within tmux, GNU Screen or a desktop environment, so if you are using GNU Screen already, you don't need to install tmux. Also, if you are running Slimv in a desktop environment, you don't really need to install either tmux or GNU Screen, although you could if you would like to see Swank running in a separate tmux or GNU Screen window rather than a separate terminal window. In this article, I am going to assume that Vim is running within tmux.\n\nIf you are going to run Slimv in a terminal without a desktop environment, tmux or GNU Screen, Swank server has to be run manually. Point 4 below explains how to do it.\n\n-\nInstalling Slimv is pretty simple. Here is one way to do it:\n\n```\ngit clone https://github.com/kovisoft/slimv.git ~/.vim/pack/plugins/start/slimv\nvim +'helptags ~/.vim/pack/plugins/start/slimv/doc' +q\n```\n\nThat is it! Slimv is set up. It's that straightforward. The commands above show how to set up Slimv with just two shell commands. You could also use a Vim plugin manager to install Slimv for you but I am not going to cover that here.\n\n-\nThis is an optional step. Slimv supports starting Swank server automatically if you are running Vim in tmux, GNU Screen or a desktop environment. To start tmux, enter this command:\n\n```\ntmux\n```\n\nIf you use GNU screen or a desktop environment, you don't have to run tmux.\n\nIf you do not use tmux, GNU Screen or a desktop environment, then you must start Swank server manually as explained in the next point.\n\n-\nThis step is necessary only if you are not using tmux, GNU Screen or a desktop environment. The following command shows how to start Swank server manually:\n\n```\nsbcl --load ~/.vim/pack/plugins/start/slimv/slime/start-swank.lisp\n```\n\nIf you are using tmux, GNU Screen or a desktop environment, Slimv can start Swank server automatically when needed and you don't need to perform this step.\n\n-\nCreate a new Lisp source code file, say,\n\n`foo.lisp`\n\nwith this command:\n\n```\nvim foo.lisp\n```\n\n-\nTo connect to Swank server, enter the following command in normal mode:\n\n`,`` c`If Vim is running within tmux, GNU Screen or desktop environment, Slimv would automatically launch Swank server and connect to it.\n\nAfter Slimv connects to Swank successfully, Vim window should split into two and the following prompt should appear in the new split window:\n\n```\nCL-USER>\n```\n\nThis is the integrated REPL. It is now alive and ready for interactive programming.\n\nWe assume here that Slimv is using the default Slimv leader key\n\n`,`. If you have overridden the Vim leader key, then the Slimv leader key might be same as the Vim leader key. Enter the command`:echo g:slimv_leader`\n\nin Vim command-line mode to find the leader key being used by Slimv. -\nType some code into the buffer for the new file. To do so, first type\n\n`i` to enter insert mode and type this code:\n\n```\n(format t \"hello, world~%\")\n```\n\nType\n\n`esc` to return to normal mode. -\nTo evaluate the current expression under the cursor, enter the following command in normal mode:\n\n`,`` e`Both the current expression and its result should appear in the REPL window.\n\n-\nThe REPL is interactive. Type\n\n`ctrl`+` w``w` to switch to the REPL window. Then type`i` to enter insert mode and type this code:\n\n```\n(+ 1 2)\n```\n\nType\n\n`enter` to evaluate the expression just like you would do in a real REPL. The result should then appear in the REPL.Type\n\n`esc` to return to normal mode again. Use the normal mode command`ctrl`+` w``w` to switch between the split windows. -\nNow that you have got started with Slimv, here is a brief note on uninstallation, in case you ever need it. If Slimv is installed as described in point 2 above, enter the following command to uninstall it:\n\n```\nrm -rf ~/.vim/pack/plugins/start/slimv\n```\n\nIn steps 7 and 9, you may have noticed that as soon as you type an\nopening parenthesis or double quotation mark, a matching closing one\nis automatically inserted. That is done by the\n[Paredit](https://github.com/kovisoft/paredit) plugin\nwhich is bundled along with Slimv. Paredit ensures structured\nediting of Lisp s-expressions and keeps all matched characters\n(parentheses, brackets, braces, quotes) balanced. It also provides\nmany new keybindings to edit s-expressions conveniently. We will\nlook into Paredit in a little more detail in\nthe [ Get Started with\nParedit](#get-started-with-paredit) subsection later.\n\n### Get Started with Vlime and SBCL\n\nHere are the steps to set up Vlime and use it:\n\n-\nInstall the tools required to set up a Common Lisp development environment with Vlime with this command:\n\n```\nsudo apt-get install vim sbcl git curl\n```\n\nNote that unlike Slimv, Vlime can work with the default Vim in Debian, i.e.\n\n`vim.basic`\n\n. Vlime does not require Vim with Python interface. -\nInstall Quicklisp with these commands:\n\n```\ncurl -O https://beta.quicklisp.org/quicklisp.lisp\nsbcl --load quicklisp.lisp --eval '(quicklisp-quickstart:install)' --eval '(exit)'\nsbcl --load ~/quicklisp/setup.lisp --eval '(ql:add-to-init-file)' --eval '(exit)'\n```\n\nType\n\n`enter` in the end, when prompted, to complete the installation. -\nInstall Vlime and Paredit with these commands:\n\n```\ngit clone https://github.com/l04m33/vlime.git ~/.vim/bundle/vlime\ngit clone https://github.com/kovisoft/paredit ~/.vim/pack/plugins/start/paredit\necho 'set runtimepath^=~/.vim/bundle/vlime/vim' >> ~/.vimrc\nvim +'helptags ~/.vim/bundle/vlime/vim/doc' +'helptags ~/.vim/pack/plugins/start/paredit/doc' +q\n```\n\nUnlike Slimv, Vlime does not bundle\n\n[Paredit](https://github.com/kovisoft/paredit)along with itself. As explained in the previous section, it helps us with structured editing of Lisp s-expressions.I recommend that you install Paredit but in case you choose not to, ensure that loading of filetype plugins is enabled by entering the\n\n`:filetype`\n\ncommand in command-line mode. The output should contain`plugin:ON`\n\n. If it is off, add the command`filetype plugin on`\n\nto`~/.vimrc`\n\nto ensure that this is always on. Vlime won't work without this being enabled. If you install Paredit, you don't have to bother about this because Paredit takes care of enabling this by default. -\nCreate a new Lisp source code file, say,\n\n`foo.lisp`\n\nwith this command:\n\n```\nvim foo.lisp\n```\n\n-\nTo start Vlime server (a wrapper around Swank server) and connect to it automatically, enter the following command in normal mode:\n\n`\\`` r``r` We assume here that Vim\n\n`<LocalLeader>`\n\nis left to its default, i.e. backslash. If it is mapped to some other key combination, then that must be used instead of backslash in the above command.The first time this command is run after installing Vlime, it installs Swank server using Quicklisp. Therefore, it can take a while for Vlime server to start the first time this command is run. On subsequent use of these commands, it would start faster because it would be already installed.\n\nThe console output from Vlime server is displayed in a split window. After Vlime successfully connects to Swank, the following message is displayed at the bottom:\n\n```\nVlime Connection 1 established.\n```\n\nAfter the above message appears, it is okay to close the split window for Vlime server by entering this command in Vim command-line mode:\n\n```\n:q\n```\n\nVlime server would continue to run in background. The following command can be used in normal mode to view the console output of Vlime server anytime it is required:\n\n`\\`` r``v` -\nType some code into the buffer for the new file. To do so, first type\n\n`i` to enter insert mode and type this code:\n\n```\n(format t \"hello, world~%\")\n```\n\nType\n\n`esc` to return to normal mode. -\nTo evaluate, the current expression under the cursor, enter the following command in normal mode:\n\n`\\`` s``s` Both the current expression and its result should appear in the REPL window.\n\nUnlike Slimv, the REPL window of Vlime is\n\n*not*interactive. Its`nomodifiable`\n\noption is set, so we cannot type code directly into the REPL window. This can be a bit of a problem if we want to type arbitrary expressions into the REPL and execute them. To mitigate this shortcoming to some extent, Vlime provides an alternative way to evaluate the current expression known as the interaction mode. This is explained in the next point. -\nEnable interaction mode by entering this command in normal mode:\n\n`\\`` i`The same command disables interaction mode, i.e. this command toggles the state of interaction mode between on and off. When interaction mode is on, evaluate an expression under the cursor by simply pressing\n\n`enter` in normal mode. -\nNow that you have got started with Vlime, here is a brief note on uninstallation, in case you ever need it. If Quicklisp and Vlime are installed as described in the points 2 and 3 above, run these commands to uninstall them:\n\n```\nrm -rf ~/quicklisp ~/.vim/bundle/vlime ~/.vim/pack/plugins/start/paredit\nsed -i.bkp '/runtimepath.*vlime/d' ~/.vimrc\n```\n\nOptionally, remove\n\n`~/.sblrc`\n\nor edit it to remove the code pertaining to loading`quicklisp/setup.lisp`\n\n.\n\n### Get Started with Paredit\n\nYou have already got started with Paredit when you wrote Lisp code while following one of the previous two subsections. The moment you typed an opening parenthesis, Paredit inserted a closing one for you automatically. Paredit keeps all matched characters such as parentheses, double quotes, etc. balanced when you edit code. Here is a very brief exercise to quickly get started with some of the very basic features of Paredit:\n\n-\nCreate a new Lisp source code file, say,\n\n`foo.lisp`\n\nwith this command:\n\n```\nvim foo.lisp\n```\n\n-\nType\n\n`i` to enter insert mode and then type only this:\n\n```\n(defun square (x\n```\n\nAt this point, Paredit should have inserted the two closing parentheses automatically. The code should look like this:\n\n```\n(defun square (x))\n```\n\nThe cursor should be situated just after the parameter\n\n`x`\n\n. The block above shows where the cursor should be. -\nWhile you are still in insert mode, type the first closing parenthesis. Yes, type it even if the closing parenthesis is already present. The cursor should now skip over the first closing parenthesis like this:\n\n```\n(defun square (x))\n```\n\nOf course, there was no need to type the closing parenthesis because it was already present but typing it out to skip over it is more efficient than escaping to normal mode, then moving over it and then entering insert mode again. This is, in fact, a very nifty feature of Paredit. We can enter code with the same keystrokes as we would without Paredit.\n\n-\nYou should still be in insert mode. Type\n\n`enter` to create a new line below. Now one of two things is going to happen. If electric return is disabled, then a newline is inserted as expected like this:\n\n```\n(defun square (x))\n  )\n```\n\nIf electric return is enabled, two newlines are inserted to create an empty line in between:\n\n```\n(defun square (x)\n   \n  )\n```\n\nIn both cases, indentation of two spaces is inserted automatically. The new empty line inserted by electric return allows linewise editing of the code to be entered in this empty line.\n\nThe electric return feature is enabled by default in both Paredit and Slimv. It works by Paredit remapping the \"enter\" key (\n\n`<CR>`\n\n) in insert mode to a function that inserts electric return. Slimv needs to remap the \"enter\" key to present the argument list of the current function but it takes care of performing an electric return before showing the argument list. Vlime, however, forgets to perform electric return before showing the argument list, so this feature does not work in Vlime.For now, we will continue with the assumption that electric return is enabled and working fine. If it is disabled or if it is not working for you, ignore the steps that discuss electric return.\n\n-\nNow, type only this:\n\n```\n(* x x\n```\n\nAgain, Paredit would have inserted the closing parenthesis automatically. The code should look like this now:\n\n```\n(defun square (x)\n  (* x x)\n  )\n```\n\n-\nNow, type one more closing parenthesis to advance past the automatically inserted closing parenthesis like this:\n\n```\n(defun square (x)\n  (* x x) \n  )\n```\n\n-\nThen type another closing parenthesis. Paredit would now pick the lone closing parenthesis that is present in its own line and move it at the end of the current line like this:\n\n```\n(defun square (x)\n  (* x x))\n```\n\nThis behaviour of consuming the extra newline inserted by an electric return on typing a closing parenthesis helps the code to conform to the popular Lisp coding convention of putting all the consecutive closing parentheses next to each other in the same line. In other words, typing closing parentheses re-gathers electric returns when applicable.\n\n-\nLet us see what happens if we try to delete the opening parenthesis around the product function (the\n\n`*`\n\nfunction). Type`esc` to return to normal mode. Then enter`h` in normal mode to move the cursor one place left so that the cursor is placed on the parenthesis just after the last`x`\n\nin the code like this:\n\n```\n(defun square (x)\n  (* x x))\n```\n\nType\n\n`x` to delete the closing parenthesis the cursor is on. Nothing gets deleted! Instead the cursor just skips over the parenthesis like this:\n\n```\n(defun square (x)\n  (* x x))\n```\n\nParedit refuses to delete the closing parenthesis because it encloses a non-empty list. It would have deleted the closing parenthesis along with the opening one if the list were empty. This is Paredit trying to ensure that the s-expressions remain valid while editing.\n\nNote that in this step,\n\n`h` is a regular Vim motion command. In Vim, by default,`x` deletes the character under the cursor, but when Paredit is enabled, it remaps this command to behave the way it did in this step to ensure that the parentheses remain balanced. -\nLet us now try to delete the current line. Type\n\n`d`` d`to do so. The result looks like this:\n\n```\n(defun square (x)\n  )\n```\n\nNote how the closing parenthesis has been left intact to keep the parentheses balanced. Again, Paredit has remapped the\n\n`d`` d`command to produce this behaviour. -\nNow type\n\n`d`` a``(` to delete the entire`defun`\n\nexpression. The buffer should look empty now. -\nType\n\n`i` to enter insert mode and type out the following code:\n\n```\n(list (* 10 20) (+ 30 40))\n```\n\n-\nType\n\n`esc` to return to normal mode. Type`h``(`` h``h` to place the cursor on the closing parenthesis of the first expression.\n\n```\n(list (* 10 20) (+ 30 40))\n```\n\nNow type\n\n`,``>`. The closing parenthesis of the first expression moves right to*slurp*the next expression. The buffer looks like this:\n\n```\n(list (* 10 20 (+ 30 40)))\n```\n\nWe assume here that Paredit is using the default Paredit leader key\n\n`,`. If you have overridden the Vim leader key, then the Paredit leader key might be same as the Vim leader key. Enter the command`:echo g:paredit_leader`\n\nin Vim command-line mode to find the leader key being used by Paredit. -\nNow type\n\n`,``<`. The closing parenthesis of the outer expression moves left to*barf*the inner expression out. The buffer looks like this again:\n\n```\n(list (* 10 20) (+ 30 40))\n```\n\nWhile the cursor is on a parenthesis, the normal mode commands\n\n`,<`\n\nor`,>`\n\ncan be used in this manner to move the parenthesis left or right respectively, thereby slurping or barfing expressions.\n\nThat was a very brief overview of what Paredit can do. There is a\nlot more to Paredit than what is described above. Paredit has a\nrich set of keybindings to make editing s-expressions very\nconvenient. Enter `:help paredit-keys`\n\nin command-line\nmode to see the list of the keybindings.\n\nI think it is a good idea to read the entire Paredit documentation.\nEnter `:help paredit`\n\nto do so. It is about 500 lines\nlong and takes about 30 to 40 minutes to read. The time spent\nreading this documentation is worth it because it makes editing Lisp\ncode very pleasant and productive.\n\n## Use Debugger and Inspector\n\nAfter getting started with Slimv or Vlime, the very next thing you might want to know is how to work with the debugger. The debugger window comes up whenever an error or an unhandled condition occurs. It might look quite scary to a beginner, so it is a good idea to become comfortable with it as soon as possible. Fortunately, both Slimv and Vlime provide excellent key-bindings to inspect the error or dismiss it to return to the source code buffer quickly and easily.\n\n### Use Debugger and Inspector with Slimv\n\nThe following steps trigger an error and then show how to work with the debugger in Slimv:\n\n-\nCreate a file with Vim, say\n\n`foo.lisp`\n\nand enter the following code into it:\n\n```\n(defun square (x)\n  (* x x))\n\n(square \"foo\")\n```\n\n-\nEnter\n\n`,`` b`to evaluate the buffer. -\nAs soon as the defective form\n\n`(square \"foo\")`\n\ngets evaluated, an error occurs. The error, possible restarts and the backtrace is displayed in a new split window for SLDB. SLDB stands for Slime Debugger. Here is an example of what may appear in the SLDB window:\n\n```\nThe value\n  \"foo\"\nis not of type\n  NUMBER\nwhen binding SB-KERNEL::X\n   [Condition of type TYPE-ERROR]\n\nRestarts:\n  0: [RETRY] Retry SLIME REPL evaluation request.\n  1: [*ABORT] Return to SLIME's top level.\n  2: [ABORT] abort thread (#<THREAD \"repl-thread\" RUNNING {1003274E23}>)\n\nBacktrace:\n  0: (SB-KERNEL:TWO-ARG-* \"foo\" \"foo\") [external]\n  1: (SQUARE \"foo\")\n  2: (SB-DEBUG::TRACE-CALL #<SB-DEBUG::TRACE-INFO SQUARE> #<FUNCTION SQUARE> \"foo\")\n  3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SQUARE \"foo\") #<NULL-LEXENV>)\n  4: (EVAL (SQUARE \"foo\"))\n  5: (SWANK::EVAL-REGION \"(defun square (x) ..)\n  6: ((LAMBDA NIL :IN SWANK-REPL::REPL-EVAL))\n  ...\n```\n\nThe ellipsis in the end is added by me to denote that the actual output has been truncated in this article for the sake of brevity.\n\n-\nIn the SLDB window, move the cursor to the second line of backtrace, i.e. on the following line:\n\n```\n  1: (SQUARE \"foo\")\n```\n\nThen type\n\n`enter`. This line should now unfold to show the following details:\n\n```\n  1: (SQUARE \"foo\")\n      in \"(SB-INT:NAMED-LAMBDA SQUARE-----------------------------------\n    Locals:\n      X = \"foo\"\n```\n\n-\nMove the cursor to the line that begins with\n\n`in`\n\n, i.e. on this line:\n\n```\n      in \"(SB-INT:NAMED-LAMBDA SQUARE-----------------------------------\n```\n\nThen type\n\n`enter`. Some information about its source code should appear like this:\n\n```\n  1: (SQUARE \"foo\")\n      in \"(SB-INT:NAMED-LAMBDA SQUARE\n    (X)\n  (BLOCK SQUARE (#:***HERE*** (* X X))))\" byte 1\n    Locals:\n      X = \"foo\"\n```\n\n-\nMove the cursor to the following line:\n\n```\n      X = \"foo\"\n```\n\nThen type\n\n`,`` i`to inspect this variable. A prompt would appear to confirm the variable name. Type`enter` to confirm. An inspector window should now appear with more details about this variable. This window should look like this:\n\n```\nInspecting #<(SIMPLE-ARRAY CHARACTER (3)) {100478AFAF}>\n--------------------\nPress <F1> for Help\n\nDimensions: (3)\nElement type: CHARACTER\nTotal size: 3\nAdjustable: NIL\nFill pointer: NIL\nContents:\n0: #\\f\n1: #\\o\n2: #\\o\n\n[<<] Exit Inspector\n```\n\n-\nType\n\n`enter` to inspect any object under the cursor and drill down further. -\nType\n\n`backspace` in normal mode to return to the previous object. -\nEnter\n\n`,`` q`in normal mode to quit the inspector. -\nFinally, move the cursor to the following line in the SLDB window:\n\n```\n  1: [*ABORT] Return to SLIME's top level.\n```\n\nThen type\n\n`enter` to execute this restart. Alternatively, enter`,`` a`in normal mode to select the abort restart and quit to the previous level or`,`` q`to quit to top level.\n\nMost of the times when an error occurs, I quickly take a look at the\nstack trace to realise that I have made a silly mistake and enter\nthe `,`` q` command to abort and quit to top level.\nThis can be quite convenient because it allows returning from\ndebugging to coding very quickly with only two keystrokes.\n\n### Use Debugger and Inspector with Vlime\n\nThe following steps trigger an error and then show how to work with the debugger in Vlime:\n\n-\nCreate a file with Vim, say\n\n`foo.lisp`\n\nand enter the following code into it:\n\n```\n(defun square (x)\n  (* x x))\n\n(square \"foo\")\n```\n\n-\nSave the file, connect to Vlime server and enter\n\n`\\`` o``f` in normal mode to compile the entire buffer. -\nAs soon as the defective form\n\n`(square \"foo\")`\n\ngets evaluated, an error occurs. The error, possible restarts and the backtrace is displayed in a new split window for SLDB. SLDB stands for Slime Debugger. Here is an example of what may appear in the SLDB window:\n\n```\nThread: 1; Level: 1\n\nThe value\n  \"foo\"\nis not of type\n  NUMBER\nwhen binding SB-KERNEL::X\n   [Condition of type TYPE-ERROR]\n\nRestarts:\n  0. *ABORT - Return to SLIME's top level.\n  1.  ABORT - abort thread (#<THREAD \"worker\" RUNNING {10045D6F83}>)\n\nFrames:\n  0.  (SB-KERNEL:TWO-ARG-* \"foo\" \"foo\") [external]\n  1.  (SQUARE \"foo\")\n  2.  (SB-FASL::LOAD-FASL-GROUP #S(SB-FASL::FASL-INPUT :STREAM #<SB-SYS:FD-STREAM for \"file /home/susam/foo.fasl\" {10045E76A3}> :TABLE #(41 #<PACKAGE \"SB-IMPL\"> SB-IMPL::%DEFUN #<PACKAGE \"COMMON-LISP-USER\">..\n  3.  (SB-FASL::LOAD-AS-FASL #<SB-SYS:FD-STREAM for \"file /home/susam/foo.fasl\" {10045E76A3}> NIL NIL)\n  4.  ((FLET SB-FASL::THUNK :IN LOAD))\n  5.  (SB-FASL::CALL-WITH-LOAD-BINDINGS #<CLOSURE (FLET SB-FASL::THUNK :IN LOAD) {7F7B9B0B60BB}> #<SB-SYS:FD-STREAM for \"file /home/susam/foo.fasl\" {10045E76A3}>)\n  ...\n```\n\nThe ellipsis in the end is added by me to denote that the actual output has been truncated in this article for the sake of brevity.\n\n-\nIn the SLDB window, move the cursor to the second line of backtrace, i.e. on the following line:\n\n```\n  1.  (SQUARE \"foo\")\n```\n\nThen type\n\n`d`. A new split window should appear with the following details about this frame:\n\n```\nFrame: 1 (Restartable)\n\nLocals:\n  X: \"foo\"\n\nLocation:\n  File: /home/susam/foo.lisp\n  Position: 20\n  Snippet:\n    (* x x))\n\n    (square \"foo\")\n```\n\n-\nWhile the cursor is on the same line as mentioned in the previous point, type\n\n`i` to bring up the inspector window for this frame. -\nIn the inspector window, type\n\n`i` to enter insert mode. Enter the following variable name in insert mode:\n\n```\nx\n```\n\nThen type\n\n`esc` to return to normal mode. Then type`enter`. The following details about the variable` x`\n\nshould now appear in the inspector window:\n\n```\n#<(SIMPLE-ARRAY CHARACTER (3)) {1004617ABF}>\n============================================\n\nDimensions: (3)\nElement type: CHARACTER\nTotal size: 3\nAdjustable: NIL\nFill pointer: NIL\nContents:\n0: #\\f\n1: #\\o\n2: #\\o\n```\n\n-\nType\n\n`enter` to inspect any object under the cursor and drill down further. -\nType\n\n`p` to return to the previous object. -\nEnter the regular Vim command\n\n`:q`\n\nin command-line mode to quit the inspector window. -\nFinally, move the cursor to the following line in the SLDB window:\n\n```\n  1: [*ABORT] Return to SLIME's top level.\n```\n\nThen type\n\n`enter` to execute this restart. Alternatively, we can enter`a` in normal mode to select the abort restart to return to the previous level. At this time, there is no command to return to SLIME's top level.\n\n## Trace Function\n\n### Trace Function in Slimv\n\nThe following steps show how to get started with tracing functions in Slimv:\n\n-\nCreate a file with Vim, say\n\n`foo.lisp`\n\nand enter the following code into it:\n\n```\n(defun square (x)\n  (* x x))\n\n(square (square 2))\n```\n\n-\nEnter\n\n`,`` b`in normal mode to evaluate the entire buffer. -\nPlace the cursor on the function name, i.e. on\n\n`square`\n\nand enter`,`` t`in normal mode to toggle tracing for this function. A prompt appears to confirm the function name. Type`enter` to confirm. -\nWhile the cursor is on the last expression, enter\n\n`,`` d`in normal mode to evaluate the top-level form. The following output appears in the REPL buffer.\n\n```\n(square (square 2))\n  0: (SQUARE 2)\n  0: SQUARE returned 4\n  0: (SQUARE 4)\n  0: SQUARE returned 16\n16\n```\n\nThis output contains information about each call to the traced function, arguments passed to it and the return values.\n\n### Trace Function in Vlime\n\nIt takes a little more work to start tracing functions in Vlime. The following steps show how to do it:\n\n-\nAdd the following statement to\n\n`~/.vimrc`\n\n:\n\n``` js\nlet g:vlime_contribs = ['SWANK-ASDF', 'SWANK-PACKAGE-FU',\n                      \\ 'SWANK-PRESENTATIONS', 'SWANK-FANCY-INSPECTOR',\n                      \\ 'SWANK-C-P-C', 'SWANK-ARGLISTS', 'SWANK-REPL',\n                      \\ 'SWANK-FUZZY', 'SWANK-TRACE-DIALOG']\n```\n\nThe above variable defines the list of Swank contrib modules to load while initialising a Vlime connection. All modules mentioned above except the last one are loaded by default. The\n\n`SWANK-TRACE-DIALOG`\n\nmodule is not loaded by default but this module is necessary for tracing functions, so in order to load it, we define this variable to load this module in addition to all the other modules that are loaded by default. -\nCreate a file with Vim, say\n\n`foo.lisp`\n\nand enter the following code into it:\n\n```\n(defun square (x)\n  (* x x))\n\n(square (square 2))\n```\n\n-\nSave the file, connect to Vlime server and enter\n\n`\\`` o``f` in normal mode to compile the entire buffer. -\nEnter\n\n`\\`` T``D` in normal mode to show the trace dialog in a split window. -\nEnter\n\n`ctrl`+` w``w` in normal mode to go back to the source code window. -\nPlace the cursor on the function name, i.e. on\n\n`square`\n\nand enter`\\`` T``T` in normal mode to toggle tracing for this function. -\nWhile the cursor is on the last expression, enter\n\n`\\`` s``t` in normal mode to evaluate the top-level form. -\nEnter\n\n`ctrl`+` w``w` in normal mode twice to go to the trace window. -\nUnder\n\n`Trace Entries`\n\n, place the cursor on`[refresh]`\n\nand type`enter`. -\nThen place the cursor on\n\n`[fetch next batch]`\n\nand type`enter`. Two results should appear for the two` square`\n\ncalls that were made due to step 7. The trace information would be folded under each call. -\nMove the cursor to each fold line and enter\n\n`z`` o`in normal mode to open the fold. After opening both the folds, the following result should be visible:\n\n```\n0 - COMMON-LISP-USER::SQUARE\n    > 2\n    < 4\n1 - COMMON-LISP-USER::SQUARE\n    > 4\n    < 16\n    16\n```\n\nThe lines starting with\n\n`>`\n\nshow the arguments and the ones starting with`<`\n\nshow the return values.\n\n## Nifty Features\n\nIn this section, we will go over some of the nifty features that these plugins offer. Not all features will be covered here. I have chosen only a few features for the discussion here that I felt would be useful to beginners and at the same time also demonstrate the versatility of these plugins.\n\n### Evaluate Top-Level Form\n\nIn the previous sections, we saw how to evaluate the current expression under the cursor. In this section, we will see how to evaluate the top-level expression around the current cursor position. Let us do a small exercise to see this:\n\n-\nCreate a file with Vim, say\n\n`foo.lisp`\n\nand enter the following code into it:\n\n```\n(+ 1 (* 2 (/ 6 2)))\n```\n\n-\nWith Slimv or Vlime connected to Swank, let us do a quick recap of how to evaluate the current expression.\n\nWith Slimv, enter the normal mode command\n\n`,`` e`to evaluate the current expression.With Vlime, enter the normal mode command\n\n`\\`` s``s` to evaluate the current expression.The current expression, i.e.\n\n`(/ 6 2)`\n\nshould get evaluated and the result`3`\n\nshould appear in the REPL buffer. -\nLet us now see how to evaluate the top-level expression.\n\nWith Slimv, enter the normal mode command\n\n`,`` d`to evaluate the top-level expression.With Vlime, enter the normal mode command\n\n`\\`` s``t` to evaluate the top-level expression.The top-level expression should get evaluated and the result\n\n`7`\n\nshould appear in the REPL buffer.\n\n### Rainbow Parentheses\n\nRainbow parentheses make it easy to see matching parentheses by\ncolouring different levels of parentheses with different colours.\nMatching parentheses have the same colour. To enable this feature\nin Slimv, add this command to `~/.vimrc`\n\n:\n\n``` js\nlet g:lisp_rainbow=1\n```\n\nThis feature is not available in Vlime. But there are several Vim plugins that support rainbow parentheses. Here are the steps to install one such plugin that is quite popular:\n\n```\ngit clone https://github.com/junegunn/rainbow_parentheses.vim.git ~/.vim/pack/plugins/start/rainbow_parentheses\necho 'autocmd FileType lisp,scheme,clojure RainbowParentheses' >> ~/.vimrc\n```\n\nIn case you ever want to uninstall it, enter these commands:\n\n```\nrm -rf ~/.vim/pack/plugins/start/rainbow_parentheses\nsed -i.bkp '/autocmd.*RainbowParentheses/d' ~/.vimrc\n```\n\n### Argument List\n\nYou must have seen this feature already while trying out the sections earlier. While editing a Lisp source file, after typing a function name, as soon as a space is typed or the enter key is typed, the argument list for the function appears to serve as a reference. In Slimv, the argument list appears in the status line at the bottom. In Vlime, the argument list appears in a split window at the top.\n\n### Omni-Completion\n\nType a function name partially, e.g. `form`\n\nand type\n`tab` while still in insert mode. The omni-completion menu\nshould appear with the list of completions if there are multiple\nchoices. Type `ctrl`+` n` to select the next choice\nand `ctrl`+` p` to select the previous choice.\nSelecting a choice also immediately inserts that choice in the\nbuffer. This works in both Slimv and Vlime. In Slimv, we can also\ntype `tab` to select the next choice.\n\nBy default, omni-completion is fuzzy. For example,\ntype `wl`\n\nand type `tab` and omni-complete\nshould insert `write-line`\n\nautomatically as well as show\nother matching choices.\n\n### Describe Symbol\n\nWith Slimv, enter the normal mode command `,`` s`\nto describe the symbol under the cursor. This brings up the\ndocumentation of the symbol in the Vim message area. This feature\nworks while editing Common Lisp and Clojure source files but not\nwhile editing Scheme source file. This feature is not supported for\nScheme at this time. See\nthe [ Other Lisp Dialects](#other-lisp-dialects)\nsection for details on how to set up Slimv with Clojure and MIT/GNU\nScheme.\n\nWith Vlime, enter `\\`` d``a` in normal\nmode to describe the symbol under the cursor. This brings up the\ndocumentation of the symbol in a split window.\n\n### Expand Macro\n\nHere is an excercise that shows how to expand macros interactively while editing a Lisp source file:\n\n-\nCreate a file with Vim, say\n\n`foo.lisp`\n\nand enter the following code into it:\n\n```\n(defmacro calc (a op b)\n  (list op a b))\n\n(defmacro square (x)\n  (list 'calc x '* x))\n\n(square 2)\n```\n\n-\nWith Slimv, enter\n\n`,`` b`in normal mode to evaluate the entire buffer.With Vlime, save the file, connect to Vlime server and type\n\n`\\`` o``f` in normal mode to compile the entire buffer. -\nWith Slimv, while the cursor is on the last expression, enter\n\n`,`` 1`in normal mode to expand the macro form once.With Vlime, enter\n\n`\\`` m``1` in normal mode to do the same thing.The following expansion should appear as the result:\n\n```\n(CALC 2 * 2)\n```\n\nSlimv displays the expansion in the REPL buffer whereas Vlime displays it in a new split window.\n\n-\nWith Slimv, enter\n\n`,`` m`in normal mode to recursively expand the current expression until it is no longer a macro.With Vlime, enter\n\n`\\`` m``a` in normal mode to do the same thing.The following expansion should appear as the result:\n\n```\n(* 2 2)\n```\n\n### Cross Reference\n\nHere is an exercise that shows how to use the cross-reference commands in Slimv and Vlime:\n\n-\nCreate a file with Vim, say\n\n`foo.lisp`\n\nand enter the following code into it:\n\n```\n(defun square (x)\n  (* x x))\n\n(defun square-of-sum (x y)\n  (square (+ x y)))\n\n(defun sum-of-squares (x y)\n  (+ (square x) (square y)))\n\n(square-of-sum 2 3)\n(sum-of-squares 2 3)\n```\n\n-\nWith Slimv, enter\n\n`,`` b`in normal mode to evaluate the entire buffer.With Vlime, save the file, connect to Vlime server and type\n\n`\\`` o``f` in normal mode to compile the entire buffer. -\nWith Slimv, place the cursor on any occurrence of the symbol\n\n`square`\n\nand enter`,`` x``l` in normal mode. A prompt would appear to confirm the symbol name. Type`enter` to confirm. The list of all callers should now appear in the REPL buffer.With Vlime, place the cursor on any occurrence of the symbol\n\n`square`\n\nand enter`\\`` x``c` in normal mode to list all callers of the function. The output appears in a split window containing the cross reference (xref) buffer. Type`enter` on any item in the xref buffer and Vlime will take you directly to the referenced location.\n\n## Other Common Lisp Implementations\n\nThe previous sections used SBCL as the implementation of Common Lisp. How well do Slimv and Vlime work with other Common Lisp implementations?\n\nI have found that both plugins are pretty well tested with SBCL. However, they may not be so well tested with other implementations. Due to the lack of sufficient testing with Common Lisp implementations other than SBCL, certain errors may occur while using other implementations. Sometimes it is possible to work around these errors and sometimes it isn't. We will see an example of this in an upcoming section when we try to start Swank server automatically using Vlime and CLISP.\n\nFor this section, I choose CLISP and Embeddable Common-Lisp (ECL) as two other implementations of Common Lisp that will be used with Slimv and Vlime. After following the upcoming subsections, you should get the hang of how to make Slimv or Vlime work with other implementations of Common Lisp.\n\n### Use Slimv with CLISP\n\nIf you have read and tried the steps in the\n[ Get Started with\nSlimv and SBCL](#get-started-with-slimv-and-sbcl) section, it is going to be quite easy to use\nSlimv with CLISP. The steps are similar with a few minor\nmodifications. They are explained below:\n\n-\nUninstall SBCL and install CLISP with these commands:\n\n```\nsudo apt-get remove sbcl\nsudo apt-get install clisp\n```\n\n-\nTo start Swank server manually, enter this command:\n\n```\nclisp ~/.vim/pack/plugins/start/slimv/slime/start-swank.lisp\n```\n\nThen edit a Lisp source file and enter the normal command\n\n`,`` c`to connect to it and bring up the REPL window. -\nTo start Swank automatically from Slimv, there is nothing more to be done. Just edit a Lisp source file and enter the normal mode command\n\n`,`` c`. While running in GNU Screen, tmux or a desktop environment, Slimv can automatically detect CLISP and start Swank server with it.\n\nIn general, to start Swank server manually with another Common Lisp\nimplementation, we need to figure out how to load\n`start-swank.lisp`\n\nwith it.\n\n### Use Slimv with ECL\n\nThe steps to use Slimv with Embeddable Common-Lisp (ECL) are very similar too. Once again, only if we need to start Swank server manually, we need to figure out the command to do so. Otherwise, there is no other difference. Here are the steps:\n\n-\nEnsure that SBCL and CLISP are uninstalled and ECL is installed.\n\n```\nsudo apt-get remove sbcl clisp\nsudo apt-get install ecl\n```\n\n-\nTo start Swank server manually, enter this command:\n\n```\necl --load ~/.vim/pack/plugins/start/slimv/slime/start-swank.lisp\n```\n\nThen edit a Lisp source file and enter the normal command\n\n`,`` c`to connect to it and bring up the REPL window. -\nTo start Swank automatically from Slimv, there is nothing more to be done. Just edit a Lisp source file and enter the normal mode command\n\n`,`` c`. While running in GNU Screen, tmux or a desktop environment, Slimv can automatically detect CLISP and start Swank server with it.There is a possible timeout issue to be aware of though. ECL can take a minute or two to compile the code it loads the first time Swank server is started. However, Slimv has a default timeout period of 20 seconds, so Slimv may fail with the following error message:\n\n```\nSWANK server is not running.  Press ENTER to continue.\n```\n\nIf this happens, just wait for ECL to complete compiling Swank server. Once it starts Swank server, enter the normal mode command\n\n`,`` c`again and it should connect immediately.\n\n### Use Vlime with CLISP\n\nThis subsection assumes that you have already read and tried the\n[ Get Started with\nVlime and SBCL](#get-started-with-vlime-and-sbcl) section, so you are familiar with Vlime\nbasics. Now we will see what more it takes to use Vlime with CLISP\nin the steps below:\n\n-\nLet us assume we want to start afresh with CLISP, i.e. we do not have previous artefacts created by SBCL. To clean up old artefacts, enter these commands:\n\n```\nrm -rf ~/.sbclrc ~/quicklisp\nsudo apt-get remove sbcl\n```\n\n-\nInstall CLISP with this command:\n\n```\nsudo apt-get install clisp\n```\n\n-\nInstall Quicklisp using CLISP with these commands:\n\n```\ncurl -O https://beta.quicklisp.org/quicklisp.lisp\nclisp -i quicklisp.lisp -x '(quicklisp-quickstart:install)'\nclisp -i ~/quicklisp/setup.lisp -x '(ql:add-to-init-file)'\n```\n\nType\n\n`enter` in the end, when prompted, to complete the installation. -\nAdd the following code to\n\n`~/.vimrc`\n\n:\n\n``` js\nlet g:vlime_cl_impl = 'clisp'\nfunction! VlimeBuildServerCommandFor_clisp(vlime_loader, vlime_eval)\n    return ['clisp', '-i', a:vlime_loader,\n                   \\ '-x', a:vlime_eval,\n                   \\ '-repl']\nendfunction\n```\n\nUnlike Slimv, automatic start of Swank server with Common Lisp implementations other than SBCL are not supported out of the box, so the above Vim script tells Vlime how to start Swank server with CLISP. The\n\n`-repl`\n\noption is used to work around an issue that is explained in the next point. -\nVlime is now ready to be used with CLISP. Just edit a Lisp source file and enter the normal mode command\n\n`\\`` r``r` to start Swank server and connect to it automatically.You may see the following error in the SLIME debugger (\n\n`sldb`\n\n) split window:\n\n```\nSOCKET-STATUS on #1=#<INPUT STRING-INPUT-STREAM> is illegal\n```\n\nDespite the above error, the following message should appear at the bottom:\n\n```\nVlime Connection 1 established.\n```\n\nIf the above message occurs, you can ignore this error, close the debugger window as well as the console output window and continue to use Vlime normally.\n\nThe\n\n`-repl`\n\noption used in the previous step ensures that the REPL starts despite this error. Without it, this step would not have succeeded. This is what I meant when I said earlier that we may need to work around certain errors while using these plugins with a Common Lisp implementation other than SBCL.\n\n### Use Vlime with ECL\n\nHere are the steps to use Vlime with ECL:\n\n-\nLet us assume we want to start afresh with ECL, i.e. we do not have previous artefacts created by SBCL or ECL. To clean up old artefacts, enter these commands:\n\n```\nrm -rf ~/.sbclrc ~/.clisprc.lisp ~/quicklisp\nsudo apt-get remove sbcl clisp\n```\n\n-\nInstall ECL with this command:\n\n```\nsudo apt-get install ecl\n```\n\n-\nInstall Quicklisp using ECL with these commands:\n\n```\ncurl -O https://beta.quicklisp.org/quicklisp.lisp\necl --load quicklisp.lisp --eval '(quicklisp-quickstart:install)' --eval '(quit)'\necl --load ~/quicklisp/setup.lisp --eval '(ql:add-to-init-file)' --eval '(quit)'\n```\n\nType\n\n`enter` in the end, when prompted, to complete the installation. -\nAdd the following code to\n\n`~/.vimrc`\n\n:\n\n``` js\nlet g:vlime_cl_impl = 'ecl'\nfunction! VlimeBuildServerCommandFor_ecl(vlime_loader, vlime_eval)\n    return ['ecl', '--load', a:vlime_loader,\n                 \\ '--eval', a:vlime_eval]\nendfunction\n```\n\n-\nEdit a Lisp source file and enter the normal mode command\n\n`\\`` r``r` to start Swank server and connect to it automatically.\n\n## Other Lisp Dialects\n\nSo far, we have seen how to use Slimv or Vlime with a Common Lisp implementation. Now let us see how well these plugins work with other Lisp dialects. Vlime does not support other Lisp dialects. It supports Common Lisp only. Slimv supports two other popular dialects of Lisp: Scheme and Clojure. In the next two subsections, we see how\n\n### Use Slimv with MIT/GNU Scheme\n\nSlimv is documented to work with MIT/GNU Scheme on Linux only.\nEnter\n`:help slimv-installation`\n\nin Vim to read more about it.\nIt says the following under the \"Prerequisites\" section.\n\nLisp or Clojure or MIT/GNU Scheme (Linux only) installed.\n\nFurther, the Swank loader script for MIT/GNU Scheme named\n`swank-mit-scheme.scm`\n\nsays the following in its source code\ncomments:\n\nYou need MIT/GNU Scheme 9.2\n\nAt the time of writing this article, I have confirmed that both these requirements indeed need to be met to use Slimv with MIT/GNU Scheme. Here are the steps to use Slimv with MIT/GNU Scheme:\n\n-\nInstall MIT/GNU Scheme with this command:\n\n```\nsudo apt-get mit-scheme\n```\n\nEnsure that\n\n`vim-nox`\n\n, tmux and Slimv are installed as explained in thesubsection earlier.*Get Started with Slimv and SBCL* -\nThis is an optional step. To start Swank server automatically from Slimv, run Vim in tmux, GNU Screen or a desktop environment. In this article, we use tmux, so start tmux with this command:\n\n```\ntmux\n```\n\n-\nThis step is necessary only if you are not using tmux, GNU Screen or a desktop environment. In such a case, enter this command to start Swank server manually:\n\n```\nscheme --load ~/.vim/pack/plugins/start/slimv/slime/contrib/swank-mit-scheme.scm\n```\n\n-\nCreate a new Scheme source code file, say,\n\n`foo.scm`\n\nwith this command:\n\n```\nvim foo.scm\n```\n\n-\nTo connect to Swank server, enter the following command in Vim normal mode:\n\n`,`` c` -\nType some code into the buffer for the new file. To do so, first type\n\n`i` to enter insert mode and type this code:\n\n```\n(display \"hello, world\\n\")\n```\n\nType\n\n`esc` to return to normal mode. To evaluate, the current expression under the cursor, enter the following command in normal mode:`,`` e`Both the current expression and its result should appear in the REPL window.\n\nI have confirmed that the steps above work fine with MIT/GNU Scheme 9.1.1 on Debian GNU/Linux 9.11 (stretch). Like I mentioned before, Slimv requires Linux to work with MIT/GNU Scheme. For example, trying to start Swank server with MIT/GNU Scheme 9.2 on macOS High Sierra 10.13.6 fails with this error:\n\n```\n; /usr/local/Cellar/mit-scheme/9.2_2/lib/mit-scheme-c/include/config.h:879:10:\nfatal error: 'sys/types.h' file not found\n```\n\nFurther, the version of MIT/GNU Scheme really needs to be 9.x. For example, when I try to start Swank with MIT/GNU Scheme 10.1.5 on Debian GNU/Linux 10.1 (buster), the following error occurs:\n\n``` php\n;The object #[package 12 (user)], passed as an argument to ->environment, is not an environment.\n```\n\n### Use Slimv with Clojure\n\nSlimv works fine with Clojure too. However, it may have some trouble locating Clojure on the system if we attempt to start Swank server automatically with Clojure. That is because where and how Clojure is installed varies from operating system to operating system and also depends on the installation procedure chosen to set up Clojure.\n\nOn Unix-like systems, Slimv looks for JAR files that match the glob\npattern `clojure*.jar`\n\nat paths that match the glob\npattern `/usr/local/bin/*clojure*`\n\nand `~/*clojure`\n\n, in that order. On Windows, it looks\nfor the JAR files at directory paths that match the glob\npattern `C:\\*clojure*`\n\nand `C:\\*clojure*\\lib`\n\n.\nAdditionally, Slimv also looks for the JAR files at the paths\nmentioned in the `PATH`\n\nenvironment variable. There are\na few more strategies too to locate Clojure but we will not get into\nthat here.\n\nIn this section, I will show how to build Clojure from source with\nMaven and install it at `~/clojure/clojure.jar`\n\n, a path\nSlimv can easily find, so installing it here would mean that the\nsteps below would work everywhere regardless of the operating\nsystem. If you are on Windows, install Clojure\nat `C:\\clojure\\clojure.jar`\n\ninstead.\n\nHere are the steps to install Clojure at\n`~/clojure/clojure.jar`\n\nand use it with Slimv:\n\n-\nChoose one of the two sets of commands below to install Maven:\n\n```\n# On Debian, Ubuntu, etc.\nsudo apt-get install maven\n\n# On macOS\nbrew install openjdk maven\nexport JAVA_HOME=/usr/local/opt/openjdk\nexport PATH=\"$JAVA_HOME/bin:$PATH\"\n```\n\n-\nEnter these commands to install Clojure:\n\n```\ngit clone https://github.com/clojure/clojure.git ~/clojure\ngit -C ~/clojure checkout clojure-1.10.1\nmvn -f ~/clojure/pom.xml -Plocal -Dmaven.test.skip=true package\n```\n\n-\nEnsure that\n\n`vim-nox`\n\n, tmux and Slimv are installed as explained in thesubsection earlier.*Get Started with Slimv and SBCL* -\nThis is an optional step. To start Swank server automatically from Slimv, run Vim in tmux, GNU Screen or a desktop environment. In this article, we use tmux, so start tmux with this command:\n\n```\ntmux\n```\n\n-\nThis step is necessary only if you are not using tmux, GNU Screen or a desktop environment. In such a case, enter these commands to start Swank server manually:\n\n```\nSWANK_DIR=~/.vim/pack/plugins/start/slimv/swank-clojure\njava -cp \"$HOME/clojure/clojure.jar:$SWANK_DIR\" clojure.main -i \"$SWANK_DIR/swank/swank.clj\" -e '(swank.swank/start-repl)' -r\n```\n\n-\nCreate a new Clojure source code file, say,\n\n`foo.clj`\n\nwith this command:\n\n```\nvim foo.clj\n```\n\n-\nTo connect to Swank server, enter the following command in Vim normal mode:\n\n`,`` c` -\nType some code into the buffer for the new file. To do so, first type\n\n`i` to enter insert mode and type this code:\n\n```\n(println \"hello, world\")\n```\n\nType\n\n`esc` to return to normal mode. To evaluate, the current expression under the cursor, enter the following command in normal mode:`,`` e`Both the current expression and its result should appear in the REPL window.\n\n## Comparison of Slimv and Vlime\n\nFinally, let me provide a comparison of both Slimv and Vlime side by side. This comparison table below is not exhaustive. There are more differences between the tools than what is mentioned below.\n\n| Slimv | Vlime |\n|---|---|\n|\nSlimv's directory structure conforms to the directory structure of plugins in a Vim package as well as the default directory structure expected by popular Vim plugin managers, so installing Slimv is quite straightforward. |\nVlime's directory structure does not conform to the\ndirectory structure of plugins in a Vim package or the\ndefault directory structure expected by popular Vim plugin\nmanagers. As a result, Vim's native support for packages\ncannot be used to install Vlime. Installing it via a plugin\nmanager requires fiddling with\nVim's |\n|\nSlimv requires a Vim package that is compiled with support for Python interface. |\nVlime does not have this requirement. It can work with basic Vim that does not have Python interface. |\n|\nSlimv requires Vim to be running within tmux, GNU Screen or a desktop environment to be able to start Swank server automatically. If you have none of these, Swank server needs to be started manually. |\nVlime does not require tmux, GNU Screen or a desktop environment in order to start Vlime server automatically. It can start Vlime server on its own. |\n|\nSlimv does not require Quicklisp to install Swank. Slimv bundles the Swank server code with itself. |\nVlime requires Quicklisp to be installed. It relies on Quicklisp to install Swank the first time it is needed. |\n|\nSlimv bundles Paredit with itself. Installing Slimv also provides Paredit. |\nVlime does not bundle Paredit with itself. Paredit needs to be installed separately. |\n|\nThe buffer for REPL is interactive in Slimv. We can type\ncode directly into the REPL window and type |\nThe buffer for REPL is not interactive in Vlime. Its\n|\n|\nParedit electric returns work fine with Slimv. Slimv remaps the \"enter\" key to show argument list of the current function after inserting electric returns. It takes care of preserving the electric return functionality of Paredit. |\nParedit electric returns do not work fine with Vlime. Vlime remaps the \"enter\" key to show argument list of the current function without inserting electric returns. |\n|\nSlimv shows argument list of a function, symbol description, etc. in the status line or message area at the bottom. |\nVlime shows argument list of a function, symbol description,\netc. in separate split windows. These are extra windows to\nskip over while cycling between windows with the normal mode\n|\n|\nSlimv shows trace results, macro expansion, cross reference, etc. in the REPL buffer. |\nVlime shows resultions of trace results, macro expansion, cross reference, etc. in split windows. These are extra windows to skip over while cycling between windows. This could feel inconvenient. |\n|\nSlimv supports programming in Common Lisp, MIT/GNU Scheme and Clojure. |\nVlime supports programming in Common Lisp only. It does not support Scheme or Clojure. |\n|\nSlimv supports rainbow parentheses by adding\n|\nVlime does not have rainbow parentheses. However, this is not a major problem because there are several independent plugins available that provide rainbow parentheses. |\n|\nSlimv cross-reference commands do not help us to jump directly to a function listed in the results. |\nVlime cross-reference commands create a xref buffer that\nallows us to jump directly to a function listed in the\nresults by moving the cursor to the function name in the\nxref buffer and typing |\n\n## Quick Recommendation\n\nIf you are looking for a quick recommendation on which plugin to use, I am going to recommend Slimv. It has been around for much longer. It supports a wider variety of Lisp implementations. I find its default key bindings more convenient. A truly interactive REPL buffer is also a bonus. Also, Slimv supports Scheme and Clojure whereas Vlime does not. Having said that, I think it is a good idea to try out both the plugins on your own and then find out which one suits you more.\n\n## Disclosure\n\nFour bugs were harmed while writing this article!\n\nWhile writing this article, I found the following four bugs in Slimv\nwhich were then promptly squashed:\n[#87](https://github.com/kovisoft/slimv/pull/87),\n[#88](https://github.com/kovisoft/slimv/pull/88),\n[#89](https://github.com/kovisoft/slimv/pull/89) and\n[#90](https://github.com/kovisoft/slimv/pull/90).", "url": "https://wpnews.pro/news/lisp-in-vim-2019", "canonical_source": "https://susam.net/lisp-in-vim.html", "published_at": "2026-05-23 14:55:59+00:00", "updated_at": "2026-05-23 15:35:10.448352+00:00", "lang": "en", "topics": ["developer-tools", "open-source"], "entities": ["Slimv", "Vlime", "Vim", "Lisp"], "alternates": {"html": "https://wpnews.pro/news/lisp-in-vim-2019", "markdown": "https://wpnews.pro/news/lisp-in-vim-2019.md", "text": "https://wpnews.pro/news/lisp-in-vim-2019.txt", "jsonld": "https://wpnews.pro/news/lisp-in-vim-2019.jsonld"}}