For a number of years now, I have been using vim as a lightweight IDE. The
ecosystem of vim addons is rich. There are numerous plugins for creating tags
to navigate a project, browse files in directories, highlight syntax and so on.
What really makes it an IDE is the ability to execute code within the context
of vim.
I realize this probably sounds 'charming' to disciples of that other
text editor, but it might seem like an unnatural urge to my vim
correligionists. The piece that glues it all together is vim-conque
. The
easiest way to get conque in ubuntu is via apt
as follows:
sudo apt-get install vim-addon-manager vim-conque
sudo vim-addons -w install conqueterm
The skinny on using conque is that you can visual-select code that you are
editing, hit <F9>
, and it will be transfered to the execution window,
newlines and all. So you can test out code while you are writing it. You
can also work the other way, testing out code in a REPL, then, when it is
working as expected, escape insert mode in the REPL, yank the working code to a
register, and copy it into the file you are working on.
Dockerfile or it didn't happen!
This kind of advice is a bit abstract, so I put a working example on github and dockerhub. You can run it yourself via docker:
# this might take a little while to download
docker pull shabbychef/vim-conque
docker run --rm -it shabbychef/vim-conque
This will feel a bit odd: when you run the last command, you are in vim, but
you are in vim in a docker container. When you terminate, your changes will
not be saved (this is the --rm
flag). Directions are given in the file
on how to start conque with a screen session. If you then start R
, it will
look like this:
You can then grab some R code in the file you are editing, hit <F9>
, and it
will execute. (You might have to hit <Enter>
to get the last line to
execute.) You should get something like this:
Go back up to the file, visually select the next block:
Hit <F9>
:
(n.b. There's a screencast of this now at the very cool asciinema )
Why not?
I started using vim as an IDE with matlab years ago. Matlab has a
nogui
mode which is actually perfect for this kind of development: you can
run code in a command line REPL, but interact with graphs, the profiler, and
set graphical breakpoints and debug in separate windows. Most of the time you
are mouseless and working in vim, but can break out into GUI land when needed.
I now use vim as an IDE for R, shell-scripting, and MySQL. I would use it for developing python, but python's bizarre ideas about whitespace would require further hackery that I have not had the time or stomach to tackle.