Find out how HackerEarth can boost your tech recruiting

Learn more
piller_image

The return of Vim and Emacs

You might have already heard the news that we just released support for vim and emacs in our code editor.

Did you know vim was released way back in 1991? Emacs is also a very old editor and its development began in 1976 and has been in active development since then. A lot of IDEs have been released after that but few have a cult following among developers like these two.

Let’s talk a little about vims and emacs and some of basic concepts.

Vim

Vim is a modal editor where the same keys take on different functions in different modes. You can use this vim cheatsheet.

Editors like vim are based on the concept of configurability. Vim can be configured according to any language. Vim8 has been released and there are a lot of features that have been added, such as-

  • Asynchronous I/O support, channels
  • Support for Jobs
  • Partials
  • Lambda and closure

I will try to show you some basic configurations that work in many languages. Then, I can show you a basic workflow in vim for starters. So let’s try to create an IDE in vim.

Vim provides a lot of features that you can install using a package manager and the most common package managers are vundle and pathogen.

git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim

First, create a .vimrc file in your home directory.

cd ~
touch .vimrc

The advantage of a vimrc file is that you can check in the file to source control. When you have to work in a new environment, you can just pull the vimrc file and then start working in the new environment. All your views and key combinations will work.

In case you have plugins configured, you can then run the following command and the plugins will get installed.

vim +PluginInstall +qall

Here is a short commented part of the .vimrc file that I use.

“ set nocompatible              " required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

set splitbelow
set splitright

"split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

" Enable folding
set foldmethod=indent
set foldlevel=99

" Enable folding with the spacebar
nnoremap <space> za

set encoding=utf-8           " maximum programming languages work best with utf-8
syntax on
colorscheme elflord
set nu                       " this will give the line number

" All of your Plugins must be added before the following line
call vundle#end()            " required

" enable filetype detection, plus loading of filetype plugins
filetype plugin on

filetype plugin indent on    " required

This should be a good base to get you started. After you are comfortable with this layout, you can edit the file according to the language that you develop in. You can check the References section for some additional reading resources. You will get the whole file here.

This is how my screen looks like when I am doing code editing.

vim_screenshot

 

Learning vim can also be fun. You can check out the vim-adventures where you can learn vim commands through gaming.

 

vimadventures

 

EMACS:

The emac code editor is similar to vim. GNU Emacs describes it as “the extensible, customizable, self-documenting, real-time display editor.”

If you are installing emacs in Ubuntu, you can follow the apt-get install command.

sudo apt-get install emacs

Once done, check if emacs is installed.

$ which emacs
/usr/bin/emacs

If we get the output, then emacs is installed.

You can then start emacs by typing just the command by itself or giving a filename as an argument. If the file exists, it opens the file. Else, it will open an empty file in the buffer and then prompt the user for the input.

If you just run the emacs command, this will open with a welcome message like the one shown below.

 

emacs

Emacs have the concept of modes for different writing styles and languages. Thus, there are modes that support all the popular languages like Python, Java, Perl, etc.

real_programmers

Source: http://xkcd.com/378/

To save the file, you use the command combination (C-x C-s), which means “press the Ctrl and x keys together and then press the Ctrl and s keys together.” This should give out a message like the one below.

Wrote /home/username/filename.py

On the other hand, if you just want to exit the file, you can press (C-x C-c) and this should give you the following output.

Save file /root/abc.py? (y, n, !, ., q, C-r, d or C-h)

You can press “n” and then this will prompt again.

Modified buffers exist; exit anyway? (yes or no)

You can then type “yes” and the emac will exit without the changes being saved.

You can start learning emacs using the following guide.

 

References:

Full Stack Python, Vim for Python development
http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/
https://engineering.hackerearth.com/2013/03/11/hackerearth-vim-plugin/
https://github.com/HackerEarth/hackerearth.vim
https://www.gnu.org/software/emacs/
https://www.emacswiki.org/emacs/LearningEmacs
https://www.digitalocean.com/community/tutorials/how-to-use-the-emacs-editor-in-linux
https://danielmiessler.com/blog/differences-vi-vim-emacs/
http://batsov.com/articles/2011/11/19/why-emacs/
http://unix.stackexchange.com/questions/986/what-are-the-pros-and-cons-of-vim-and-emacs

Hackerearth Subscribe

Get advanced recruiting insights delivered every month

Related reads

The complete guide to hiring a Full-Stack Developer using HackerEarth Assessments
The complete guide to hiring a Full-Stack Developer using HackerEarth Assessments

The complete guide to hiring a Full-Stack Developer using HackerEarth Assessments

Fullstack development roles became prominent around the early to mid-2010s. This emergence was largely driven by several factors, including the rapid evolution of…

Best Interview Questions For Assessing Tech Culture Fit in 2024
Best Interview Questions For Assessing Tech Culture Fit in 2024

Best Interview Questions For Assessing Tech Culture Fit in 2024

Finding the right talent goes beyond technical skills and experience. Culture fit plays a crucial role in building successful teams and fostering long-term…

Best Hiring Platforms in 2024: Guide for All Recruiters
Best Hiring Platforms in 2024: Guide for All Recruiters

Best Hiring Platforms in 2024: Guide for All Recruiters

Looking to onboard a recruiting platform for your hiring needs/ This in-depth guide will teach you how to compare and evaluate hiring platforms…

Best Assessment Software in 2024 for Tech Recruiting
Best Assessment Software in 2024 for Tech Recruiting

Best Assessment Software in 2024 for Tech Recruiting

Assessment software has come a long way from its humble beginnings. In education, these tools are breaking down geographical barriers, enabling remote testing…

Top Video Interview Softwares for Tech and Non-Tech Recruiting in 2024: A Comprehensive Review
Top Video Interview Softwares for Tech and Non-Tech Recruiting in 2024: A Comprehensive Review

Top Video Interview Softwares for Tech and Non-Tech Recruiting in 2024: A Comprehensive Review

With a globalized workforce and the rise of remote work models, video interviews enable efficient and flexible candidate screening and evaluation. Video interviews…

8 Top Tech Skills to Hire For in 2024
8 Top Tech Skills to Hire For in 2024

8 Top Tech Skills to Hire For in 2024

Hiring is hard — no doubt. Identifying the top technical skills that you should hire for is even harder. But we’ve got your…

Hackerearth Subscribe

Get advanced recruiting insights delivered every month

View More

Top Products

Hackathons

Engage global developers through innovation

Hackerearth Hackathons Learn more

Assessments

AI-driven advanced coding assessments

Hackerearth Assessments Learn more

FaceCode

Real-time code editor for effective coding interviews

Hackerearth FaceCode Learn more

L & D

Tailored learning paths for continuous assessments

Hackerearth Learning and Development Learn more