{"id":68,"date":"2008-03-13T06:18:04","date_gmt":"2008-03-12T22:18:04","guid":{"rendered":"http:\/\/www.sysadmindayph.com\/blog\/vi-search-and-replace-the-basics-dummys-reference\/"},"modified":"2008-03-13T06:18:04","modified_gmt":"2008-03-12T22:18:04","slug":"vi-search-and-replace-the-basics-dummys-reference","status":"publish","type":"post","link":"https:\/\/www.sysadmindayph.com\/blog\/vi-search-and-replace-the-basics-dummys-reference\/","title":{"rendered":"vi Search and Replace&#8230; The Basics, Dummy&#8217;s Reference"},"content":{"rendered":"<p>Yep, this is a dummy&#8217;s reference&#8230; I keep on forgetting the syntax so I might as well put it here for my own reference&#8230; \ud83d\ude00<\/p>\n<p>vi is the one, if not the most popular text editor available for a System Administrator on a UNIX and UNIX-like machines.<\/p>\n<p>It has two modes, command and editor mode.<\/p>\n<p>Here are some syntax in using the Search and Replace in &#8216;vi&#8217;.<\/p>\n<p>Search:<\/p>\n<p>The most basic and most easily remembered command for searching is vi is <em>slash <\/em>or &#8216;\/&#8217; followed by the character being searched. That&#8217;s for forward searching. For backward, vi use &#8216;?&#8217; followed by the string being searched.<\/p>\n<p>To go to the next occurrance of the string being searched, vi use &#8216;n&#8217; command. Doesn&#8217;t matter if your searching forward (from up, down) or backward, from down to top.<\/p>\n<p>Example:<\/p>\n<p>(you have to be in command mode&#8230; press ESC first)<\/p>\n<p>\/<em>search_string<\/em><\/p>\n<p>?<em>search_string<\/em><\/p>\n<p><strong>Search and Replace<\/strong><\/p>\n<p>For search and replace, use the syntax<\/p>\n<p>:%s\/original\/replaced\/g<\/p>\n<p>Make sense?<br \/>\nAny command that begins with a &#8220;<tt>:<\/tt>&#8221; is called a line mode command and performs its duty on the line the cursor is currently on.<\/p>\n<p>The above syntax serves my purpose now&#8230; If I want to replace text in certain ranges.. <a href=\"http:\/\/unix.t-a-y-l-o-r.com\/VBsr.html\">syntax can be found here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yep, this is a dummy&#8217;s reference&#8230; I keep on forgetting the syntax so I might as well put it here for my own reference&#8230; \ud83d\ude00 vi is the one, if not the most popular text &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,5,8,3],"tags":[],"class_list":["post-68","post","type-post","status-publish","format-standard","hentry","category-linux","category-solaris","category-tips","category-unix"],"_links":{"self":[{"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/comments?post=68"}],"version-history":[{"count":0,"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/posts\/68\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/media?parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/categories?post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/tags?post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}