{"id":212,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:25:59","modified_gmt":"2020-08-22T20:25:59","slug":"this-is-the-page-title-toplevel-47","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=212","title":{"rendered":"Configuring vi"},"content":{"rendered":"\n<page pageid=\"48\" pagepath=\"\/Linux_Tutorial\/Editing_Files\/Vi\/Configuring_vi.html\">\n     <copyright id=\"1\">\n              <licensetype id =\"1\" text=\"modified GNU Free Documentation License (Portions of this material originally published by Prentice Hall, Pearson Education, Inc)\">\n              <owner id=\"1\" text=\"James Mohr\">\n              <date text=\"2002-2004\">\n     <\/copyright>\n     <moreinfos>\n          <moreinfo id=\"214\" description=\"Vim HOWTO\" location=\"\/\/www.tldp.org\/HOWTO\/Vim-HOWTO.html\" \/>\n          <moreinfo id=\"382\" description=\"Linux.Org\" location=\"\/\/www.linux.org\" \/>\n          <moreinfo id=\"381\" description=\"Linux Knowledge Portal\" location=\"\/\/www.linux-knowledge-portal.org\" \/>\n          <moreinfo id=\"379\" description=\"Unix Guru's Universe\" location=\"\/\/www.ugu.com\" \/>\n          <moreinfo id=\"383\" description=\"Linux Documentation Project\" location=\"\/\/www.tldp.org\" \/>\n          <moreinfo id=\"397\" description=\"Linux Newbie\" location=\"\/\/www.linuxnewbie.org\/\" \/>\n          <moreinfo id=\"398\" description=\"Linux Planet\" location=\"\/\/www.linuxplanet.com\/linuxplanet\/\" \/>\n          <moreinfo id=\"407\" description=\"Linux Links\" location=\"\/\/www.linuxlinks.com\/\" \/>\n          <moreinfo id=\"408\" description=\"Linux Center\" location=\"\/\/www.portalux.com\/\" \/>\n          <moreinfo id=\"412\" description=\"Linux Headquarters\" location=\"\/\/www.linuxhq.com\/\" \/>\n          <moreinfo id=\"415\" description=\"Everything Linux\" location=\"\/\/everythinglinux.org\" \/>\n          <moreinfo id=\"442\" description=\"Linux Questions\" location=\"\/\/www.linuxquestions.org\/\" \/>\n          <moreinfo id=\"1478\" description=\"Loads of Linux Links\" location=\"\/\/loll.sourceforge.net\/linux\/links\/index.html\" \/>\n          <moreinfo id=\"1489\" description=\"Mad Penguin\" location=\"\/\/www.madpenguin.org\/\" \/>\n          <moreinfo id=\"1490\" description=\"Just Learning Links\" location=\"\/\/www.just-learning-links.com\" \/>\n     <\/moreinfos>\n     <glossaryterms>\n          <glossaryterm id=\"452\" term=\"text\" \/>\n     <\/glossaryterms>\n     <commands>\n          <command id=\"1682\" commandname=\"vi\" mansection=\"1\" \/>\n     <\/commands>\n     <topics>\n          <topic id=\"9\" text=\"Working with the System\" \/>\n     <\/topics>\n<>\n<title>Configuring vi<\/title>\n<question id=\"\" type=\"mc\" text=\"What file is used to configure 'vi'?\" \/>\n<concept id=\"\" description=\"The .exrc is used to configure 'vi'.\" \/>\n<p>\nWhen we first started talking about <command>vi<\/command>, I mentioned that there were a lot things we could do to configure it. There are mappings and abbreviations and settings that we can control. The\nproblem is that once we leave vi, everything we added is lost.\nFortunately, there is hope. Like many programs, vi has its own configuration\nfile: <file type=\"\">.exrc<\/file> (note the dot at the front).\n<\/p>\n<p>\nTypically, <command>vi<\/command> just uses its standard settings and does not create this file on its own. However,\nif this file resides in our <glossary>home directory<\/glossary>, it will be valid every\ntime we start <command>vi<\/command> unless we have an .<command>exrc<\/command>file in our <i>current<\/i> directory, which will then take precedence. Having multiple <command>.exrc<\/command> files is useful when doing programming as well as when editing text. When writing text, I don&#8217;t need line numbers or autoindent like I do when programming.\n<\/p>\n<p>\nThe content and syntax of the lines is exactly the same as in vi; however, we\ndon&#8217;t have the leading\ncolon. Part of the <file type=\"\">.exrc<\/file> file in my text\nediting directory looks like this:<\/p>\n<p>\n<screenoutput>map! ^X :wq<br \/>\nmap x :wq<br \/>\nmap! ^W :w<br \/>\nmap w :w<br \/>\nset showmode<br \/>\nset wm=3<br \/>\nabbr Unix UNIX<br \/>\nabbr btwn between<br \/>\nabbr teh the<br \/>\nabbr refered referred<br \/>\nabbr waht what  <br \/>\nabbr Para {P}<br \/>\nabbr inot into<br \/>\n<\/screenoutput>\n<\/p>\n<concept id=\"\" description=\"By default, 'vi' will look in the current directory for an .exrc file\" \/>\n<p>\nBy default, <command>vi<\/command> will look in the current directory for an <file type=\"\">.exrc<\/file>.\nThis is useful for having different version for different tasks, for example, one for programming and\none for normal editing. If there is no <command>.exrc<\/command> in the current directory, <command>vi<\/command> will look for one in your home directory.\n<\/p>\n<concept id=\"\" description=\"When running 'vi' as root, the .exrc always read from root's hoem directory.\" \/>\n<question id=\"\" type=\"tf\" text=\"For security reasons, when running 'vi' as root, the .exrc always read from root's hoem directory. \" \/>\n<p>\nOne important caveat is that the, for the root <em>only<\/em> the <file>.exrc<\/file> in root&#8217;s home directory will be used. This is for security reasons. If an <file>.exrc<\/file> file was used in the current directory, a nefarious user could add something that might do something unexpected.\n<\/p>\n<concept id=\"\" description=\"The global configuration file for 'vim' is \/etc\/vimrc.\" \/>\n<p>\nIf you are using the improved version of <command>vi<\/command>, <command>vim<\/command>, there is also the <file type=\"\">\/etc\/vimrc<\/file>, which applies to all users.\n<\/p>\n<\/content>\n<\/page>\n","protected":false},"excerpt":{"rendered":"<p>Configuring vi When we first started talking about vi, I mentioned that there were a lot things we could do to configure it. There are mappings and abbreviations and settings that we can control. The problem is that once we &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=212\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-212","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/212\/revisions"}],"predecessor-version":[{"id":528,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/212\/revisions\/528"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}