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.
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:
- Learn the basic VIM modal style editing commands like
yfor yank, and
h j k lfor navigating.
/- brings up search inside the same file, after typing
N- next search and previous search respectively
spc /- Search text in files
spc p f- Search file inside the project - projects are automatically recognized if they are git directories and show up later in your recent projects
spc p l- Switch project
spc p- brings up mini buffer showing all possible project-related commands
spc b- brings up all the buffer related commands
spc b p- previous buffer - similarly
spc b nfor next buffer
spc p t- opening neotree for the birds-eye view
spc f T- show file in NeoTree, helps in understanding where actually the file resides
spc j l- jump to line
spc j w- jump to a word
- To search text only in certain types of files in a project, use
--filetype. For eg, to search for the text
importbut only in JS files bring up search project using
spc /and then search for
spc q qquit 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
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.
Top comments (0)