{"id":4435,"date":"2018-11-25T15:46:02","date_gmt":"2018-11-25T15:46:02","guid":{"rendered":"https:\/\/www.blopig.com\/blog\/?p=4435"},"modified":"2018-11-25T15:47:41","modified_gmt":"2018-11-25T15:47:41","slug":"vim-and-i","status":"publish","type":"post","link":"https:\/\/www.blopig.com\/blog\/2018\/11\/vim-and-i\/","title":{"rendered":"Vim and I"},"content":{"rendered":"<p><span class=\"TextRun SCXW35304883\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW35304883\">Vim is great. Despite its <a href=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*w9dLy2njrrkNUQVugpF-6g.jpeg\">steep learning curve<\/a>\u00a0, it has many advantages and many loyal Vim followers will tell you that you should force yourself to use it.<\/span><\/span><\/p>\n<p>Personally I started using Vim when I was ssh-ing into the group servers or into my computer in department. In such scenarios, I could not open the IDEs with the nice GUIs \ud83d\ude41\u00a0<span class=\"TextRun SCXW35304883\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW35304883\">However, as time passed, Vim started to grow on me. Now, I can list a few reasons why I think it is great, for example,<\/span><\/span><span class=\"TextRun SCXW35304883\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW35304883\">\u00a0it requires a small amount of memory to run, has a short start up time\u00a0and can handle large files pretty well.\u00a0<\/span><\/span><\/p>\n<p><span class=\"TextRun SCXW35304883\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW35304883\">Although, I am definitely not a Vim expert, I will tell you about some of the things I have added to my <code>.vimrc<\/code>.<\/span><\/span><span class=\"TextRun SCXW35304883\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW35304883\">\u00a0The <code>.vimrc<\/code> file is very handy for containing all your favourite settings, such as\u00a0key mappings, custom commands, formatting and syntax highlighting.<\/span><\/span><span class=\"TextRun SCXW35304883\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW35304883\"> The file uses vimscript which is a programming language in itself. However, there is a lot of help online that tells you with what lines to add to your<code> .vimrc<\/code>. I would recommend installing <a href=\"https:\/\/github.com\/VundleVim\/Vundle.vim\">Vundle<\/a>\u00a0which is a Vim plugin manager.\u00a0<\/span><\/span><\/p>\n<p><span class=\"TextRun SCXW35304883\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW35304883\">Here I will list some cool things that I have discovered you can do with your <code>.vimrc<\/code>.\u00a0 \u00a0It has certainly made\u00a0my life a bit nicer. <\/span><\/span><\/p>\n<ol>\n<li><span class=\"TextRun SCXW115252617\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW115252617\"><strong>Code Folding<\/strong><br \/>\nMost IDEs provide a way to collapse functions and classes that results in only seeing the function\/class definition and hiding the code. To do this in Vim add the following lines to your <code>.<\/code><\/span><\/span><code><span class=\"TextRun SCXW115252617\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"SpellingError SCXW115252617\">vimrc<\/span><\/span><span class=\"LineBreakBlob BlobObject DragDrop SCXW115252617\"><span class=\"SCXW115252617\">\u00a0<\/span><\/span><\/code><code><code><\/code><\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-linenumbers=\"false\">\" Enable folding\r\nset\u00a0foldmethod=indent\r\nset\u00a0foldlevel=99\r\n\" Enable folding with the spacebar\r\nnnoremap\u00a0&lt;space&gt; za<\/pre>\n<p><code><code><\/code><\/code><span class=\"TextRun SCXW115252617\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW115252617\"><br \/>\nAlternatively, you can install the Vim plugin <a href=\"https:\/\/github.com\/tmhedberg\/SimpylFold\">SimpylFold<\/a>.<\/span><\/span><\/li>\n<li><strong>Python indentation<\/strong><br \/>\n<span class=\"TextRun SCXW197386312\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW197386312\">Vim does not do auto indention like many IDEs. To automatically do PEP-8 indentation for Python, add the following to your .<\/span><\/span><span class=\"TextRun SCXW197386312\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"SpellingError SCXW197386312\">vimrc .\u00a0<\/span><\/span><span class=\"LineBreakBlob BlobObject DragDrop SCXW197386312\"><span class=\"LineBreakBlob BlobObject DragDrop SCXW197386312\"><span class=\"SCXW197386312\"><br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-linenumbers=\"false\">\" PEP indentation\r\nau\u00a0BufNewFile,BufRead\u00a0*.py\r\n\\ set\u00a0tabstop=4\u00a0 \u00a0 \r\n\\ set\u00a0softtabstop=4\u00a0\u00a0\u00a0 \r\n\\ set\u00a0shiftwidth=4\u00a0\u00a0\u00a0 \r\n\\ set\u00a0textwidth=79\u00a0\u00a0\u00a0 \r\n\\ set\u00a0expandtab\u00a0\u00a0\u00a0 \r\n\\ set\u00a0autoindent\u00a0\u00a0\u00a0 \r\n\\ set\u00a0fileformat=unix\r\n<\/pre>\n<p><code><\/code><\/p>\n<p><span class=\"TextRun SCXW155530403\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW155530403\"><span class=\"TextRun SCXW197386312\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"SpellingError SCXW197386312\">You can also install the Vim plugin\u00a0<a href=\"https:\/\/github.com\/nvie\/vim-flake8\">vim-flake8<\/a>\u00a0which is a static syntax and style checker for Python source code. It shows errors in a quickfix window and lets you jump to their location inside your code.<\/span><\/span><\/span><\/span><\/li>\n<li><strong><span class=\"TextRun SCXW155530403\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW155530403\">Turn line numbers on<\/span><\/span><\/strong><span class=\"LineBreakBlob BlobObject DragDrop SCXW155530403\"><strong><span class=\"SCXW155530403\">\u00a0<\/span><\/strong><br class=\"SCXW155530403\" \/><\/span><span class=\"TextRun SCXW155530403\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW155530403\">Rather than typing in\u00a0<\/span><\/span><span class=\"LineBreakBlob BlobObject DragDrop SCXW155530403\"><span class=\"SCXW155530403\">\u00a0<\/span><br class=\"SCXW155530403\" \/><\/span><code><span class=\"TextRun SCXW155530403\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW155530403\">:set nu<\/span><\/span><\/code><span class=\"LineBreakBlob BlobObject DragDrop SCXW155530403\"><code><span class=\"SCXW155530403\">\u00a0<\/span><\/code><br class=\"SCXW155530403\" \/><\/span><span class=\"TextRun SCXW155530403\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW155530403\">every time you\u00a0<\/span><\/span><span class=\"TextRun SCXW155530403\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"ContextualSpellingAndGrammarError SCXW155530403\">open<\/span><\/span><span class=\"TextRun SCXW155530403\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW155530403\">\u00a0your files. You can always have them turned on by\u00a0<\/span><\/span><span class=\"TextRun SCXW155530403\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"ContextualSpellingAndGrammarError SCXW155530403\">adding :set<\/span><\/span><span class=\"TextRun SCXW155530403\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW155530403\">\u00a0nu to your <code>.<\/code><\/span><\/span><code><span class=\"TextRun SCXW155530403\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"SpellingError SCXW155530403\">vimrc<\/span><\/span><\/code><\/li>\n<li><strong><span class=\"TextRun SCXW58643318\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW58643318\">Autocompletion<\/span><\/span><\/strong><span class=\"LineBreakBlob BlobObject DragDrop SCXW58643318\"><strong><span class=\"SCXW58643318\">\u00a0<\/span><\/strong><br class=\"SCXW58643318\" \/><\/span><span class=\"TextRun SCXW58643318\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW58643318\">When I switch from PyCharm to Vim I feel a bit lost without the autocompletion however, after a quick search I found many are using the Vim package\u00a0<\/span><\/span><a href=\"https:\/\/github.com\/Valloric\/YouCompleteMe\"><span class=\"TextRun SCXW58643318\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"SpellingError SCXW58643318\">Youcompleteme<\/span><\/span><\/a><span class=\"TextRun SCXW58643318\" lang=\"EN-GB\" xml:lang=\"EN-GB\"><span class=\"NormalTextRun SCXW58643318\">\u00a0and it is awesome.\u00a0<\/span><\/span><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Vim is great. Despite its steep learning curve\u00a0, it has many advantages and many loyal Vim followers will tell you that you should force yourself to use it. Personally I started using Vim when I was ssh-ing into the group servers or into my computer in department. In such scenarios, I could not open the [&hellip;]<\/p>\n","protected":false},"author":38,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","wikipediapreview_detectlinks":true,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"ngg_post_thumbnail":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29,10],"tags":[],"ppma_author":[530],"class_list":["post-4435","post","type-post","status-publish","format-standard","hentry","category-code","category-groupmeetings"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"authors":[{"term_id":530,"user_id":38,"is_guest":0,"slug":"susan","display_name":"Susan Leung","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/e1a367a2f8d7409be8aa6d2beff2d277525c90331ec34202854a9a5116b4eaa4?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/4435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/comments?post=4435"}],"version-history":[{"count":5,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/4435\/revisions"}],"predecessor-version":[{"id":4445,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/4435\/revisions\/4445"}],"wp:attachment":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/media?parent=4435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/categories?post=4435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/tags?post=4435"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=4435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}