{"id":710,"date":"2010-05-14T14:06:02","date_gmt":"2010-05-14T08:36:02","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=710"},"modified":"2010-06-09T15:22:54","modified_gmt":"2010-06-09T09:52:54","slug":"vi-editor","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/vi-editor\/","title":{"rendered":"Vi Editor"},"content":{"rendered":"<p>I will try my best to give you some tips to make Vi look more interesting and easy to use for all you guys. I have read few articles and tutorials about Vi and will try to summarize some key points here.<\/p>\n<p>First things, first : WHAT IS Vi?<\/p>\n<p>Vi is NOT just an editor. It has evolved to be something more than just a plain text-editor with cool features. It can easily be an IDE for programmers (but only after you become an expert in Vi). But before going into how Vi can help you in technical terms, I would like to emphasize about how to &#8216;let go&#8217; of the fear of using a Vi editor.<\/p>\n<p>Vi is your friend. An interesting friend. Only you have to know its language (read commands). The good thing about Vi is that it lets you perform create, edit, delete, save, find, count, select, copy\/paste and so many other operations without forcing you to move your hands away from the home keys\/home row (and yes, I am talking about the home keys of &#8216;Touch Typing&#8217; fame). Just with a single keystroke or a combination of few keystrokes you can literally achieve anything you want to do while text-editing your documents or coding a super-cool program and that too all in a comfort of your keyboard and nice placement of your hands.<\/p>\n<p>The learning curve is steep, I agree but the ROI is steeper. It is more about how you see Vi. A capable editor or a demanding one. I read few articles; used it a little bit and am convinced that it is a capable editor.<\/p>\n<p>Let&#8217;s start with the basics now:<\/p>\n<p><strong>Let&#8217;s DO away with mouse. I WANNA move around through the keyboard.<\/strong><\/p>\n<p>The home keys, again !!! Hit h,j,k,l \u2013 to move left, down, up, and right respectively.<br \/>\nA nice tip to remember the movement keys :<\/p>\n<p>h is on the left \u2013 so left it goes,<\/p>\n<p>l is on the right \u2013 so right it goes,<\/p>\n<p>j looks like a down arrow key \u2013 so down it goes,<\/p>\n<p>k\u00a0 (well the only way to go now is UP) \u2013 so up it goes.<\/p>\n<p>If you have a photographic memory, this <a href=\"http:\/\/www.tentacle.franken.de\/adm3a\/adm3a-hjkl.jpg\" target=\"_blank\">picture<\/a> might help you. This is an <a href=\"http:\/\/www.tentacle.franken.de\/adm3a\/\" target=\"_blank\">ADM3A<\/a> terminal, the type of machine used originally by Bill Joy (the creator of Vi) to code the C shell on which Vi runs. This could be the reason why h,j,k,l are movement keys.<\/p>\n<p><strong>The modes in Vi : Command mode and Insert mode.<\/strong><\/p>\n<p>The name says it all. In the Command mode, Vi waits for your commands i.e. the keystrokes to let you copy, move, replace, delete, change, go to a particular line\/word etc. The good thing about Vi is it gives you different ways to achieve the same thing. You want to go end of current line: you can achieve that in different ways<\/p>\n<p>Way 1 \u2013 Pressing l (the small L) again and again till you reach end of line.<\/p>\n<p>Way 2 \u2013 Press e (command to go to end of the word) again and again till you reach your destination.<\/p>\n<p>Way 3 &#8211;\u00a0 Press f (command to find a character) followed by the character (which is the last character of your line) again and again to reach the end of line.<\/p>\n<p>Example: \u201cThis is a sample line.\u201d<\/p>\n<p>Now, to reach the end of this line(assuming your cursor is somewhere on the line) all you have to do is press &#8216;f&#8217; followed by &#8216;.&#8217;\u00a0 since &#8216;.&#8217; &#8211; period is the last character of your line.<\/p>\n<p>Way 4 \u2013 Just hit the dollar sign i.e. &#8216;$&#8217;.<\/p>\n<p>And this list is still not exhaustive, I believe. The more familiar you will become with Vi the more ways you will have to achieve the things. Some smarter ways, some dumber ways. But they all will get the job done.<\/p>\n<p>The second mode is the<strong> Insert mode<\/strong>. In this mode, the Vi takes a back seat (to say so) and lets you\u00a0 modify the contents of your document the way you want to. It is the normal text edit mode that we work on while using Notepad, Wordpad, MS Word, gedit and so on.<\/p>\n<p>Well, the good place to start learning Vi is vimtutor. Open the shell(terminal) for Linux, type in &#8216;vimtutor&#8217; and &#8216;get going&#8217; !! It is an interactive tutorial which lets you practice while you learn.<\/p>\n<p>On the ending note, I wish you all good time with Vi and will try to continue writing more about Vi editor in the future blogs.<\/p>\n<p>&#8211; Abhishek<\/p>\n<p>[Intelligrape Software Pvt. Ltd.]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I will try my best to give you some tips to make Vi look more interesting and easy to use for all you guys. I have read few articles and tutorials about Vi and will try to summarize some key points here. First things, first : WHAT IS Vi? Vi is NOT just an editor. [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2},"categories":[1],"tags":[235,236],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/710"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=710"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/710\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}