Emulating Spacemacs bindings for IDEs

Let’s face it, Spacemacs the vim-like version of Emacs is pretty awesome. Sylvain Benner and the team of contributors have made foraying into the world of Emacs for a noob like me pretty much painless. Gone are the days of having to build up your Emacs config for months or even years before you can finally make it function like the way you want to. Some people might say that’s part of the fun but hey for a graduate student juggling 6 different classes, I didn’t have the time to build my config up.

I used Spacemacs so much so that I missed having that mnemonics style keystrokes for other IDEs that I occasionally used for different reasons. You might be asking why I am using other IDEs since I have Spacemacs but let’s face it products like Jetbrain’s IntelliJ gets you going fast without having to deal with the notoriously complicated steps required to emulate IntelliJ in Emacs.

As such, here are a few ways to emulate the mnemonics style keystrokes of Spacemacs for a few on the popular IDEs around the internet.

Jetbrain Products (IntelliJ IDEA, PyCharm, CLion)

The process for setting up the bindings in IntelliJ or any other Jetbrains product is thankfully very painless.

First, go to File -> Settings -> Plugins -> Search for IdeaVim -> Install IdeaVim

Just like that you now have vim emulation, you can turn this vim emulation on by going Tools -> Click Vim Emulator. It’s as simple as that.

Now, since we are trying to emulate Spacemacs-like bindings, we need to add a vimrc file at your home directory. Since, you are trying to emulate Spacemacs binding, I assume that you have Spacemacs. Go and create a file under your home to look like something like this “~/.ideavimrc”. What this is will do is that vim emulator on your Jetbrain product will read the bindings you have in your .ideavimrc file and adjust your keybindings accordingly.

I provided my configuration for Jetbrains products below but feel free to make any changes to it. After, you pasted and saved the configuration and restart the IDE, Voila! You now have Spacemacs-like binding for your Jetbrains product!

Visual Studio Code

For Visual Studio Code, there is a whole GitHub project dedicated to it called VSpaceCode. Check out the GitHub project, it’s pretty awesome so follow the instructions and you will be up and running in no time!

Netbeans

So, I was forced to use Netbeans for a class that will go unnamed here at CMU (MISM people will know what I am talking about) so it goes without saying that I found the experience of using Netbeans pretty horrifying compared to IntelliJ or even VSCode. Nonetheless, I was able to emulate some of the Spacemacs functionality by using the jVi plugin. This plugin, however buggy, proved to the most important plugin in making Netbeans bearable.

To set up jVi, go to Tools -> Plugins -> Available Plugins -> Search for jVi -> Check jVi for NB-7.0 Update Center and install -> Click Check for Newest. Now you should be able search for jVi and select jVi for NetBeans and install. You might have to restart after installing. You should now see jVi under Tools menu and just check it to activate the vim-bindings.

If you were hoping for a vimrc-like script to emulate the Spacemacs experience in Netbeans, here is where I stop you. No. I have spent hours upon hours trying to replicate it but I had to give up in the end. Unless you want to create new Java code to customize it more, you are out of luck.

However, I was able to map some important commands to jVi by going to Tools -> Options -> jVi Config -> Map Commands. Paste the gist below into the text-box and now you are able to run things by doing rr and do some limited frame window navigation like you do in Spacemacs.

Now, go forth and enjoy your coding with the key bindings that you have become accustomed to!