{"componentChunkName":"component---src-pages-markdown-remark-fields-slug-js","path":"/engineering/vim-getting-started/","result":{"data":{"markdownRemark":{"id":"2651ac20-8db3-54c4-85aa-459ab1043fdf","excerpt":"The acronym for Vim is Vi IMproved. Written by Bram Moolenaar, it is a free and open-source text editor. It was first released for UNIX variants in 1991, and…","html":"<p>The acronym for Vim is Vi IMproved. Written by <a href=\"https://en.wikipedia.org/wiki/Bram_Moolenaar\">Bram Moolenaar</a>, it is a free and open-source text editor. It was first released for UNIX variants in 1991, and its primary purpose was to develop the Vi editor, which was released back in 1976.</p>\n<p>Vim is Vi's newest and most popular reincarnation that supports both text and graphical interfaces and is supported on any known platform.</p>\n<p>The issue with learning Vim is not that it's challenging to do. It's that you have to continue to do it. This guide aims to break the loop so that for the last time, you can learn it.</p>\n<p>The purpose of this tutorial is to take you through every step of progress from understanding the philosophy of Vim. In short, in a way that sticks with you for a lifetime, we're going to master Vim.</p>\n<p>Let's start off!</p>\n<h2 id=\"what-is-vim\" style=\"position:relative;\"><a href=\"#what-is-vim\" aria-label=\"what is vim permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is Vim?</h2>\n<p>Vim is a text editor for Unix that comes with Linux, BSD, and macOS. It is known to be fast and powerful, partly because it is a small program that can run in a terminal (although it has a graphical interface). It is mainly because it can be managed entirely without menus or a mouse with a keyboard.</p>\n<p>For the following five reasons, I feel people should use Vim:</p>\n<ol>\n<li>It's omnipresent. You don't have to think about learning about several boxes with a new editor.</li>\n<li>It is highly scalable. You can use it only to edit configuration files or become your entire forum for writing.</li>\n<li>It has a shallow memory footprint.</li>\n<li>It's command-centered. With a few commands, you can perform complex text-related tasks.</li>\n<li>It is highly configurable and uses simple text files to store its settings.</li>\n</ol>\n<h2 id=\"why-use-vim\" style=\"position:relative;\"><a href=\"#why-use-vim\" aria-label=\"why use vim permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why Use Vim?</h2>\n<p>In all POSIX systems, Vim is the default fallback editor. Vim is sure to be open, whether you have just installed the operating system, or you have booted into a minimal system repair environment, or you are unable to access any other editor. While you can switch out other tiny editors on your systems, such as GNU Nano or Jove, it's Vim that's all but guaranteed to be on every other system in the world.</p>\n<p>In short, I think competence with Vim should be considered the way you view competence with your native language, or simple maths, etc. In technology, so much begins with understanding your editor.</p>\n<p>Also, It is <strong>extremely customizable</strong> and you can adapt it to your way of coding and your way of doing things.\nTo give you a taste of vim , below are a few commands frequently used to code at lightning speed:</p>\n<ul>\n<li>hjkl : move the cursor around to left, down, up, and right respectively.</li>\n<li>7j : move 7 lines down.</li>\n<li>w : move a word forward</li>\n<li>ctrl + f : move down a page</li>\n<li>ctrl + b : move up a page</li>\n<li>gg : move to the top of the document</li>\n<li>G : move to the bottomost of the document</li>\n<li>dw : delete a word</li>\n<li>d6w : delete 6 words</li>\n<li>dt> : delete till  <code>></code></li>\n<li>di] : delete everything inside <code>[ ]</code></li>\n<li>dd : delete whole line</li>\n<li>4dd : delete 4 lines</li>\n<li>yy : yank a line ( yank is copy )</li>\n<li>cc : change a line ( change is delete and go in insert mode )</li>\n<li>cap : change a paragraph</li>\n<li><code>.</code> : repeat last command</li>\n<li>f' : find first occurance of <code>'</code></li>\n<li>f'ci'hello : _find the next  <code>'</code> then change everything inside <code>'</code> for <code>hello</code></li>\n</ul>\n<p>The list goes on and on... </p>\n<p>Basically we have standard keybindings like d for delete, c for change, f for find etc. and we can pair them with numbers to repeat that action n number of times. Moreover doubling a command like so <code>yy</code> makes the command operate on the entire line.</p>\n<p>So to sum up,</p>\n<blockquote>\n<p>Vim is for <strong>programmers who want to raise their game</strong>. In the hands of an expert, It shreds text at the speed of thought.</p>\n</blockquote>\n<h4 id=\"how-to-use-vim\" style=\"position:relative;\"><a href=\"#how-to-use-vim\" aria-label=\"how to use vim permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How to use Vim</h4>\n<p> Well, there is a learning curve, but it's worth it. Although this steep curve is exaggerated in the online world and the <strong>quitting vim joke</strong> is getting very old (It's:q btw).</p>\n<p> Install Vim <code>sudo apt-get vim or pacman -S vim</code> for Linux user and type <code>vim &#x3C;filename></code> in your terminal. Press <code>i</code> to go to insert mode. Type some gibberish. Press <code>:wq</code> to save and quit . <code>:q!</code> to quit without saving.</p>\n<p> First of all, don't get disheartened when you see VIM for the first time, it's known to make a <strong>horrible first impression.</strong> We'll learn to customize it later in the blog.</p>\n<p> <img src=\"/30e4bc97b173caff9cce44962cb4a78b/BadVim.webp\" alt=\"BadVim\"></p>\n<p> To get started, get your hands dirty on <strong>vimtutor</strong> . It's a 20-30 minute vim tutorial which teaches you all the basics. Just type <code>vimtutor</code> in your terminal (in a machine where you have vim installed) to open it.</p>\n<p><strong>Try  <a href=\"https://vim-adventures.com/\">Vim Adventures</a></strong>. An interactive game that teaches you vim skills in a step by step manner and lets you unlock new abilities after you've proved your worth with the previous ones.</p>\n<p> Just get started with it . <strong>Learn as you go</strong> . You can always refer to the <a href=\"https://vim.rtorr.com/\">Vim CheatSheet</a> to get better. Practice makes a man perfect. Watch screencasts if that's helpful (was helpful to me).</p>\n<h2 id=\"how-do-i-configure-my-vim-\" style=\"position:relative;\"><a href=\"#how-do-i-configure-my-vim-\" aria-label=\"how do i configure my vim  permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How do I configure my Vim ?</h2>\n<p>The best way to configure your Vim is through <code>.vimrc</code> file, which is hidden inside your home directory. Open a terminal and type <code>vim ~/.vimrc</code> to open your vimrc file using vim. Cool huh? Using vim to configure vim ..no? Nevermind!\nHere you can define your keybindings, set themes, install plugins etc.</p>\n<p>Here is an example of a custom keybinding\n<code>map &#x3C;C-n> :NERDTreeToggle&#x3C;CR></code>\nYou can check out this <a href=\"https://hea-www.harvard.edu/~fine/Tech/vi.html\">article</a> on keybindings and how to use them.</p>\n<p>The easiest way to download and manage plugins for vim is by using a plugin manager. There are quite a few <a href=\"https://github.com/tpope/vim-pathogen\">vim-pathogen</a> , <a href=\"https://github.com/VundleVim/Vundle.vim\">Vundle.vim</a> , <a href=\"https://github.com/junegunn/vim-plug\">Vim-plug</a> etc.\nVim-plug being my favourite. Installations and usage for each plugin manager can be found in their respective repositories.</p>\n<p>I personally like to call all my plugins in a separate file and link that file to my vimrc. Paste this line in your vimrc at the top if you want to do the same <code>source ~/.vim/plugin/plugins.vim</code>\nIn your plugins.vim file you can install different plugins like this:-</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">call plug#begin(&#39;~/.vim/plugged&#39;)</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">Plug &#39;scrooloose/nerdtree&#39;</span>\n<span class=\"grvsc-line\">Plug &#39;moll/vim-node&#39;</span>\n<span class=\"grvsc-line\">Plug &#39;yegappan/mru&#39;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">call plug#end()</span></code></pre>\n<p>The first and last lines are for vim-plug to know what plugins are to be installed. The lines beginning with <code>Plug</code> is to install that particular plugin.</p>\n<p>Now just reload .vimrc (or quit vim and re-enter) and <code>:PlugInstall</code> to install plugins.</p>\n<h2 id=\"what-are-some-good-plugins-for-vim\" style=\"position:relative;\"><a href=\"#what-are-some-good-plugins-for-vim\" aria-label=\"what are some good plugins for vim permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What are some good plugins for Vim?</h2>\n<p>Glad you asked because Vim is no fun without plugins made by the awesome open source community.\nHere are some good plugins you should definitely install. Just search these on GitHub in case you wanna know more about them or their usage.</p>\n<ul>\n<li>scrooloose/nerdtree</li>\n<li>alvan/vim-closetag</li>\n<li>vim-scripts/vim-auto-save</li>\n<li>airblade/vim-gitgutter</li>\n<li>ervandew/supertab</li>\n<li>vim-airline/vim-airline</li>\n<li>SirVer/ultisnips</li>\n<li>honza/vim-snippets</li>\n<li>dense-analysis/ale</li>\n<li>tpope/vim-repeat</li>\n<li>ap/vim-css-color</li>\n<li>jiangmiao/auto-pairs</li>\n<li>tmhedberg/matchit</li>\n<li>kana/vim-textobj-user</li>\n<li>vim-scripts/tComment</li>\n<li>Valloric/YouCompleteMe', { 'do': './install.py --tern-completer' }</li>\n<li>prettier/vim-prettier', { 'do': 'yarn install' }</li>\n<li>jeffkreeftmeijer/vim-numbertoggle</li>\n<li>elzr/vim-json</li>\n<li>tpope/vim-markdown</li>\n<li>pangloss/vim-javascript</li>\n<li>mxw/vim-jsx</li>\n<li>jparise/vim-graphql</li>\n<li>leafgarland/typescript-vim</li>\n<li>vim-syntastic/syntastic</li>\n<li>ntpeters/vim-better-whitespace</li>\n</ul>\n<p>Pheww!!..\nSo you see there's a plugin for anything and everything. These plugins are more than enough to make vim a full-blown IDE.</p>\n<h3 id=\"summing-up\" style=\"position:relative;\"><a href=\"#summing-up\" aria-label=\"summing up permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summing up!!</h3>\n<p>VIM makes you write code at the speed of thoughts. Just get started, and the rest will follow. Steal your friend's vimrc or find one on the internet (there are tons of them) if you don't want to make one of your own.</p>\n<p>If you want to slowly blend in into the world of vim then use some vim plugin for your text editor. All popular text editors have a vim plugin ( <a href=\"https://marketplace.visualstudio.com/items?itemName=vscodevim.vim\">Here's one for VsCode </a>)\nHere you go, best of both worlds! When you're comfortable enough, go for that complete switch.</p>\n<p><img src=\"/83a1cd4054ef50dc629a6846d30d87b3/vscodevim.webp\" alt=\"vscodevim\"></p>\n<p>Here's how my vim setup looks.</p>\n<p><img src=\"/aa9e337b13aca7c3043c49bba3b61a23/Vim.webp\" alt=\"Vim\"></p>\n<p>Now go give it a try. I wish you luck!!</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n</style>","headings":[{"value":"What is Vim?","depth":2},{"value":"Why Use Vim?","depth":2},{"value":"How to use Vim","depth":4},{"value":"How do I configure my Vim ?","depth":2},{"value":"What are some good plugins for Vim?","depth":2},{"value":"Summing up!!","depth":3}],"fields":{"slug":"/engineering/vim-getting-started/"},"frontmatter":{"metatitle":null,"metadescription":null,"description":"Vim is Vi's newest and most common reincarnation that is supported on every known platform, check out the article to learn about what is ViM, and why to use it.","title":"Vim: What is it and Why to use it?","canonical":null,"date":"October 08, 2020","updated_date":null,"tags":["Vim","Text Editor"],"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/aa9e337b13aca7c3043c49bba3b61a23/2ad7f/Vim.webp","srcSet":"/static/aa9e337b13aca7c3043c49bba3b61a23/1c9b5/Vim.webp 200w,\n/static/aa9e337b13aca7c3043c49bba3b61a23/f1752/Vim.webp 400w,\n/static/aa9e337b13aca7c3043c49bba3b61a23/2ad7f/Vim.webp 800w,\n/static/aa9e337b13aca7c3043c49bba3b61a23/e7405/Vim.webp 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Shubhankar Khare","github":"iamshubhankarkhare","bio":"He is a passionate full stack web developer from India. He loves learning new technologies and is an open source enthusiast.","avatar":null}}}},"pageContext":{"id":"2651ac20-8db3-54c4-85aa-459ab1043fdf","fields__slug":"/engineering/vim-getting-started/","__params":{"fields__slug":"engineering"}}},"staticQueryHashes":["1171199041","1384082988","1711371485","1753898100","2100481360","229320306","23180105","528864852"]}