{"id":298,"date":"2018-08-15T08:40:54","date_gmt":"2018-08-15T05:40:54","guid":{"rendered":"https:\/\/blog.arcak.net\/?p=278"},"modified":"2018-08-15T11:32:28","modified_gmt":"2018-08-15T08:32:28","slug":"vi-editoru-usage","status":"publish","type":"post","link":"https:\/\/blog.arcak.net\/index.php\/2018\/08\/15\/vi-editoru-usage\/","title":{"rendered":"Using the Vi Editor"},"content":{"rendered":"<p style=\"text-align: justify;\"><strong>What is the Vi editor?<\/strong><\/p>\n<p style=\"text-align: justify;\">Vi is a Notepad-like tool for editing text files from the command line, widely used in the Linux\/Unix community. Although it was often thought that Unix had been written by this tool, <strong>Vi<\/strong> was originally developed by <strong>Bill Joy<\/strong> in <strong>1976<\/strong>.<strong> (Unix is based on the year 1969<\/strong>.)\u00a0According to my personal experience, I can say that 50% of Linux\/Unix use is Vi. The beginners have bad experience of editor usage and usually cool open source operating systems off when they are not comfortable to use. <strong>(The remaining 50% is the use of shell)<\/strong><\/p>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-280 aligncenter\" src=\"https:\/\/blog.arcak.net\/wp-content\/uploads\/2018\/08\/vi-editor-300x248.png\" alt=\"\" width=\"300\" height=\"248\" srcset=\"https:\/\/blog.arcak.net\/wp-content\/uploads\/2018\/08\/vi-editor-300x248.png 300w, https:\/\/blog.arcak.net\/wp-content\/uploads\/2018\/08\/vi-editor-768x634.png 768w, https:\/\/blog.arcak.net\/wp-content\/uploads\/2018\/08\/vi-editor-660x545.png 660w, https:\/\/blog.arcak.net\/wp-content\/uploads\/2018\/08\/vi-editor.png 800w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p style=\"text-align: justify;\"><!--more--><\/p>\n<p><strong>How does Vi work?<\/strong><\/p>\n<p style=\"text-align: justify;\">Works in 3 different modes;<\/p>\n<ol style=\"text-align: justify;\">\n<li><strong>VI<\/strong>: The editor starts working in this mode, most of the keys on the keyboard are assigned to specific commands. The <strong>ESC<\/strong> key is pressed to return from other modes.<\/li>\n<li><strong>Inpu<\/strong>t: You must be in <strong>VI<\/strong> mode before you switch to this mode. You can toggle by pressing the <strong>&#8220;:&#8221; (colon)<\/strong>, the only exception is to be able to search the status <strong>&#8220;\/&#8221; <\/strong>(forward slash).<\/li>\n<li>Command: A mode that allows a user to input data into files.<\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><strong>What are the Vi shortcuts?<\/strong><\/p>\n<p style=\"text-align: justify;\">If we summarize the shortcuts for three types, we will encounter a table like the following.<\/p>\n<ul>\n<li style=\"text-align: justify;\">To display the tables correctly on your mobile device, enable the desktop view in your browser.<\/li>\n<\/ul>\n<table style=\"border-collapse: collapse; width: 80.7392%; height: 456px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: center;\"><strong>Vi<\/strong><\/td>\n<td style=\"width: 23.2289%; height: 24px; text-align: center;\"><strong>Input<\/strong><\/td>\n<td style=\"width: 29.1242%; height: 24px; text-align: center;\"><strong>Command<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><\/td>\n<td style=\"width: 23.2289%; height: 24px; text-align: left;\"><strong>ESC<\/strong> to exit<\/td>\n<td style=\"width: 29.1242%; height: 24px; text-align: left;\"><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca\/documents\/basic\/img18.png\" alt=\"$ leftarrow $\" width=\"23\" height=\"19\" align=\"BOTTOM\" border=\"0\" \/>\u00a0<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca\/documents\/basic\/img19.png\" alt=\"$ downarrow $\" width=\"14\" height=\"35\" align=\"MIDDLE\" border=\"0\" \/>\u00a0<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca\/documents\/basic\/img20.png\" alt=\"$ uparrow $\" width=\"14\" height=\"35\" align=\"MIDDLE\" border=\"0\" \/>\u00a0<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca\/documents\/basic\/img21.png\" alt=\"$ rightarrow $\" width=\"24\" height=\"19\" align=\"BOTTOM\" border=\"0\" \/>\u00a0-Cursor keys<\/td>\n<td style=\"width: 23.2289%; height: 24px; text-align: left;\"><strong>i\u00a0<\/strong>&#8211; insert<\/td>\n<td style=\"width: 29.1242%; height: 24px; text-align: left;\"><strong>:q\u00a0<\/strong>&#8211; Quit<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><strong>H J k<\/strong> L &#8211;\u00a0Cursor\u00a0keys<\/td>\n<td style=\"width: 23.2289%; height: 24px; text-align: left;\"><strong>a\u00a0<\/strong>&#8211; append<\/td>\n<td style=\"width: 29.1242%; height: 24px; text-align: left;\"><strong>:q! <\/strong>-Output without saving<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><strong>CTRL-f\u00a0<\/strong>&#8211; Move forward on the screen<\/td>\n<td style=\"width: 23.2289%; height: 24px; text-align: left;\"><strong>A\u00a0<\/strong>&#8211; Append EOL<\/td>\n<td style=\"width: 29.1242%; height: 24px; text-align: left;\"><strong>:w\u00a0<\/strong>&#8211; Write<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><strong>CTRL-b<\/strong>\u00a0&#8211;\u00a0Go back on screen<\/td>\n<td style=\"width: 23.2289%; height: 24px; text-align: left;\"><strong>O<\/strong> &#8211; Open line<\/td>\n<td style=\"width: 29.1242%; height: 24px; text-align: left;\"><strong>:Wq<\/strong> &#8211; Write and quit<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><strong>G\u00a0<\/strong>&#8211; Go to end of file<\/td>\n<td style=\"width: 23.2289%; height: 24px; text-align: left;\"><strong>R\u00a0<\/strong>&#8211; Replace character<\/td>\n<td style=\"width: 29.1242%; height: 24px; text-align: left;\"><strong>:num\u00a0<\/strong>&#8211; Go to line num<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><strong>x\u00a0<\/strong>&#8211; Delete character<\/td>\n<td style=\"width: 23.2289%; height: 24px; text-align: left;\"><strong>R<\/strong> &#8211; Overwrite<\/td>\n<td style=\"width: 29.1242%; height: 24px; text-align: left;\"><strong>\/str\u00a0<\/strong>&#8211; Find str<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><strong>dw<\/strong>\u00a0&#8211; Delete word<\/td>\n<td style=\"width: 23.2289%; height: 24px; text-align: center;\"><\/td>\n<td style=\"width: 29.1242%; height: 24px; text-align: left;\"><strong>:set all\u00a0<\/strong>&#8211; vi settings<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><b>dd\u00a0<\/b>&#8211;\u00a0Delete line<\/td>\n<td style=\"width: 23.2289%; height: 24px; text-align: center;\"><\/td>\n<td style=\"width: 29.1242%; height: 24px; text-align: left;\"><strong>:r file<\/strong> &#8211; Import file<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><strong>yy\u00a0<\/strong>&#8211; Copy line to clipboard<\/td>\n<td style=\"width: 23.2289%; text-align: center; height: 24px;\"><\/td>\n<td style=\"width: 29.1242%; text-align: center; height: 24px;\"><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><strong>D &#8211;\u00a0<\/strong>Delete to EOL<\/td>\n<td style=\"width: 23.2289%; text-align: center; height: 24px;\"><\/td>\n<td style=\"width: 29.1242%; text-align: center; height: 24px;\"><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><strong>p <\/strong>&#8211; Paste \/ put buffer<\/td>\n<td style=\"width: 23.2289%; text-align: center; height: 24px;\"><\/td>\n<td style=\"width: 29.1242%; text-align: center; height: 24px;\"><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; height: 24px; text-align: left;\"><strong>U\u00a0<\/strong>&#8211; Undo last command<\/td>\n<td style=\"width: 23.2289%; text-align: center; height: 24px;\"><\/td>\n<td style=\"width: 29.1242%; text-align: center; height: 24px;\"><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; text-align: left; height: 24px;\"><strong>CTRL-R\u00a0<\/strong>&#8211; Redo last undo<\/td>\n<td style=\"width: 23.2289%; text-align: center; height: 24px;\"><\/td>\n<td style=\"width: 29.1242%; text-align: center; height: 24px;\"><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; text-align: left; height: 24px;\"><b>n\u00a0<\/b>&#8211; Find next occurrence of string<\/td>\n<td style=\"width: 23.2289%; text-align: center; height: 24px;\"><\/td>\n<td style=\"width: 29.1242%; text-align: center; height: 24px;\"><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 28.3284%; text-align: left; height: 24px;\"><b>cw\u00a0<\/b>&#8211; Change Word<\/td>\n<td style=\"width: 23.2289%; text-align: center; height: 24px;\"><\/td>\n<td style=\"width: 29.1242%; text-align: center; height: 24px;\"><\/td>\n<\/tr>\n<tr style=\"height: 48px;\">\n<td style=\"width: 28.3284%; text-align: left; height: 48px;\"><strong># command<\/strong> &#8211; repeat command # times<\/td>\n<td style=\"width: 23.2289%; text-align: center; height: 48px;\"><\/td>\n<td style=\"width: 29.1242%; text-align: center; height: 48px;\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>What is the Vi editor? Vi is a Notepad-like tool for editing text files from the command line, widely used in the Linux\/Unix community. Although it was often thought that Unix had been written by this tool, Vi was originally developed by Bill Joy in 1976. (Unix is based on the year 1969.)\u00a0According to my [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[161,159,163],"tags":[112,114],"class_list":["post-298","post","type-post","status-publish","format-standard","hentry","category-linux","category-open-source","category-unix","tag-linux-en","tag-unix-en"],"_links":{"self":[{"href":"https:\/\/blog.arcak.net\/index.php\/wp-json\/wp\/v2\/posts\/298"}],"collection":[{"href":"https:\/\/blog.arcak.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.arcak.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.arcak.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.arcak.net\/index.php\/wp-json\/wp\/v2\/comments?post=298"}],"version-history":[{"count":10,"href":"https:\/\/blog.arcak.net\/index.php\/wp-json\/wp\/v2\/posts\/298\/revisions"}],"predecessor-version":[{"id":330,"href":"https:\/\/blog.arcak.net\/index.php\/wp-json\/wp\/v2\/posts\/298\/revisions\/330"}],"wp:attachment":[{"href":"https:\/\/blog.arcak.net\/index.php\/wp-json\/wp\/v2\/media?parent=298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.arcak.net\/index.php\/wp-json\/wp\/v2\/categories?post=298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.arcak.net\/index.php\/wp-json\/wp\/v2\/tags?post=298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}