I have been using VScode for as long as I started with Javascript. The first editor that I ever wrote code on was Turbo C++ (yes, I started with C++ too). Turbo C++ did not look the best - it was a blue screen with no proper font rendering. However, it was good enough for doing the school assignments and small programs in c++ like a simple calculator program or a program to calculate areas of different polygons. A whole lot changed when I encountered CodeBlocks
, it was the first IDE where I had written c/c++ code with features like auto-completion and having the ability to create projects and compile code without going back to the terminal. Since that time I had always been in love with IDEs & editors.
When I started with Javascript development, I searched for the best IDE which could run at decent hardware without much lag. Most of the good IDE's were either paid or were too slow and didn't appeal to me. VSCode(not considered an IDE) pulled me in with its customizations, extensions, plugins, and various other features. I continued using VSCode throughout my college life and during internships.
By this time I was aware of VIM and had already tried it once, but it looked like some stone age tool that only the finest of the programmers use, guess what? The one time when I started my VIM, I was not able to quit it. However, it always appealed to me, the style of editing, the ability to do so much without ever reaching out to your mouse. I know that this could be done with other code editors too but it is not as efficient as it is with VIM.
There were few major issues however that were hindering my urge to adopt VIM as my editor:-
I did not know/was not very familiar with the usual VIM key bindings.
While I did not even know the editing basics, it would have been difficult to learn and customize all the stuff to one's need and I gauged that it would be quite difficult since VIM was used only by the ELITES.
I also heard about this other mystic tool called EMACS. EMACS was also supposed to be used only by the Grey-Beard Unix folks and I read in one forum that it had a much more steep learning curve.
Years later.... (well not so many.. maybe 1 - 2 years later)
I have found about Spacemacs. Spacemacs is emacs distribution (flavor of emacs sort of) that comes pre-configured with required stuff, yet providing all the abilities to customize emacs powers directly or through the spacemacs config file. The best thing about Spacemacs was, I did not have to think of the difficulty in creating a good dev environment in VIM or the difficult key bindings of emacs. Spacemacs supports both VIM & EMACS style, also has a hybrid mode.
Still, directly writing code in spacemacs would have significantly hindered my productivity while working, so I followed the following approach -
Setup VSpaceCode - Gives you mnemonics and spacemacs style key bindings support on VSCode with VIM style modal editing.
With this setup, I was still in a familiar environment and whenever I felt like I have to do things faster I could just turn off the keybindings and boom I was back in normal VSCode editing with both mouse and keyboard. This helped me with getting familiar with the basics like how to move between windows, buffers, and how to create new files, how to delete texts multiple on lines, etc.
Watch some youtube videos of spacemacs by Seorenn. These were very helpful in terms of getting up to speed with basic navigation directly on Emacs as well as show me various additional layers that I could install which could make my workflow better and motivate me more to use emacs.
Having done that, I started putting a more hands-on approach. As soon as I was comfortable with the bindings using the VSpacecode extension, I switched fully to Spacemacs for work-related projects too, and since I code daily at work, I just got better at the general modal based editing, navigating in Spacemacs, etc.
Below I have listed down a few key bindings that will help you get started quickly editing and navigating on Spacemacs and will help you not feel overwhelmed:
d
for delete, x
for cut, p
for paste
, y
for yank, and h j k l
for navigating./
- brings up search inside the same file, after typing /
enter the search text
.n
N
- next search and previous search respectivelyspc /
- Search text in filesspc p f
- Search file inside the project - projects are automatically recognized if they are git directories and show up later in your recent projectsspc p l
- Switch projectspc p
- brings up mini buffer showing all possible project-related commandsspc b
- brings up all the buffer related commandsspc b p
- previous buffer - similarly spc b n
for next bufferspc p t
- opening neotree for the birds-eye viewspc f T
- show file in NeoTree, helps in understanding where actually the file residesspc j l
- jump to linespc j w
- jump to a word--filetype
. For eg, to search for the text import
but only in JS files
bring up search project using spc /
and then search for import --js
.spc q q
quit spacemacs.So this blog post was my short journey on how I came to actually use Emacs + VIM for writing code on a day to day basis. Something which I would have never imagined doing considering the difficult reputation of VIM and Emacs in the community. I think while these things are difficult and perhaps even a lifetime is short to master them, the entry has been made pretty easy with tools like Spacemacs
, and with enough motivation, you will shortly start doing a lot of things the EVIL
way.
PS: The above commands are only for VIM mode or Hybrid mode.
Also, By the time I wrote this post, I actually stopped using Spacemacs
and instead moved to doom-emacs which is a lighter distribution but contains pre-configured with most of the necessary things and is in active development as of now. The keybindings are very spacemacy
, so the transition was swift. Also, load times are fast af.