{"id":762,"date":"2010-09-29T16:37:33","date_gmt":"2010-09-29T16:37:33","guid":{"rendered":"http:\/\/wiki.freeiz.com\/?p=762"},"modified":"2016-08-09T12:03:27","modified_gmt":"2016-08-09T12:03:27","slug":"linux-vi-editor","status":"publish","type":"post","link":"https:\/\/wiki-see.info\/wp\/2010\/09\/29\/linux-vi-editor\/","title":{"rendered":"Linux: vi Editor"},"content":{"rendered":"<h3>To Get Into and Out Of <tt>vi<\/tt><\/h3>\n<h4>To Start <tt>vi<\/tt><\/h4>\n<dl>\n<dd>To use <tt>vi<\/tt> on a file, type in <tt>vi filename<\/tt>. If the file named <tt>filename<\/tt> exists, then the first page (or screen) of the file will be displayed; if the file does not exist, then an empty file and screen are created into which you may enter text. <\/dd>\n<\/dl>\n<table border=\"1\">\n<tbody>\n<tr>\n<th>*<\/th>\n<th align=\"left\"><tt>vi filename<\/tt><\/th>\n<td><em>edit <tt>filename<\/tt> starting at line 1<\/em><\/td>\n<\/tr>\n<tr>\n<th><\/th>\n<th align=\"left\"><tt>vi -r filename<\/tt><\/th>\n<td><em>recover <tt>filename<\/tt> that was being edited when system crashed<\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>To Exit <tt>vi<\/tt><\/h4>\n<dl>\n<dd>Usually the new or modified file is saved when you leave <tt>vi<\/tt>. However, it is also possible to quit <tt>vi<\/tt> without saving the file. <\/dd>\n<dd><strong>Note:<\/strong> The cursor moves to bottom of screen whenever a colon (<tt>:<\/tt>) is typed. This type of command is completed by hitting the <tt>&lt;Return&gt;<\/tt> (or <tt>&lt;Enter&gt;<\/tt>) key. <\/dd>\n<\/dl>\n<table border=\"1\">\n<tbody>\n<tr>\n<th>*<\/th>\n<th align=\"left\"><tt>\ud83d\ude21<\/tt><tt>&lt;Return&gt;<\/tt><\/th>\n<td><em>quit <tt>vi<\/tt>, writing out modified file to file named in original invocation<\/em><\/td>\n<\/tr>\n<tr>\n<th><\/th>\n<th align=\"left\"><tt>:wq<\/tt><tt>&lt;Return&gt;<\/tt><\/th>\n<td><em>quit <tt>vi<\/tt>, writing out modified file to file named in original invocation<\/em><\/td>\n<\/tr>\n<tr>\n<th><\/th>\n<th align=\"left\"><tt>:q<\/tt><tt>&lt;Return&gt;<\/tt><\/th>\n<td><em>quit (or exit) <tt>vi<\/tt><\/em><\/td>\n<\/tr>\n<tr>\n<th>*<\/th>\n<th align=\"left\"><tt>:q!<\/tt><tt>&lt;Return&gt;<\/tt><\/th>\n<td><em>quit <tt>vi<\/tt> even though latest changes have not been saved for this <tt>vi<\/tt> call<\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Deleting Text<\/h4>\n<dl>\n<dd>The following commands allow you to delete text. <\/dd>\n<\/dl>\n<table border=\"1\">\n<tbody>\n<tr>\n<th>*<\/th>\n<th align=\"left\"><tt>x<\/tt><\/th>\n<td><em>delete single character under cursor<\/em><\/td>\n<\/tr>\n<tr>\n<th><\/th>\n<th align=\"left\"><tt>Nx<\/tt><\/th>\n<td><em>delete N characters, starting with character under cursor<\/em><\/td>\n<\/tr>\n<tr>\n<th><\/th>\n<th align=\"left\"><tt>dw<\/tt><\/th>\n<td><em>delete the single word beginning with character under cursor<\/em><\/td>\n<\/tr>\n<tr>\n<th><\/th>\n<th align=\"left\"><tt>dNw<\/tt><\/th>\n<td><em>delete <tt>N<\/tt> words beginning with character under cursor;<br \/>\ne.g., <tt>d5w<\/tt> deletes 5 words<\/em><\/td>\n<\/tr>\n<tr>\n<th><\/th>\n<th align=\"left\"><tt>D<\/tt><\/th>\n<td><em>delete the remainder of the line, starting with current cursor position<\/em><\/td>\n<\/tr>\n<tr>\n<th>*<\/th>\n<th align=\"left\"><tt>dd<\/tt><\/th>\n<td><em>delete entire current line<\/em><\/td>\n<\/tr>\n<tr>\n<th><\/th>\n<th align=\"left\"><tt>Ndd<\/tt> <em>or<\/em> <tt>dNd<\/tt><\/th>\n<td><em>delete <tt>N<\/tt> lines, beginning with the current line;<br \/>\ne.g., <tt>5dd<\/tt> deletes 5 lines<\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Cutting and Pasting Text<\/h4>\n<dl>\n<dd>The following commands allow you to copy and paste text. <\/dd>\n<\/dl>\n<table border=\"1\">\n<tbody>\n<tr>\n<th><\/th>\n<th align=\"left\"><tt>yy<\/tt><\/th>\n<td><em>copy (yank, cut) the current line into the buffer<\/em><\/td>\n<\/tr>\n<tr>\n<th><\/th>\n<th align=\"left\"><tt>Nyy<\/tt> <em>or<\/em> <tt>yNy<\/tt><\/th>\n<td><em>copy (yank, cut) the next N lines, including the current line, into the buffer<\/em><\/td>\n<\/tr>\n<tr>\n<th><\/th>\n<th align=\"left\"><tt>p<\/tt><\/th>\n<td><em>put (paste) the line(s) in the buffer into the text after the current line<\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>To Get Into and Out Of vi To Start vi To use vi on a file, type in vi filename. If the file named filename exists, then the first page (or screen) of the file will be displayed; if the file does not exist, then an empty file and screen are created into which you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[429,463],"class_list":["post-762","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux-editor","tag-linux-vi"],"_links":{"self":[{"href":"https:\/\/wiki-see.info\/wp\/wp-json\/wp\/v2\/posts\/762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wiki-see.info\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wiki-see.info\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wiki-see.info\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wiki-see.info\/wp\/wp-json\/wp\/v2\/comments?post=762"}],"version-history":[{"count":1,"href":"https:\/\/wiki-see.info\/wp\/wp-json\/wp\/v2\/posts\/762\/revisions"}],"predecessor-version":[{"id":4771,"href":"https:\/\/wiki-see.info\/wp\/wp-json\/wp\/v2\/posts\/762\/revisions\/4771"}],"wp:attachment":[{"href":"https:\/\/wiki-see.info\/wp\/wp-json\/wp\/v2\/media?parent=762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wiki-see.info\/wp\/wp-json\/wp\/v2\/categories?post=762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wiki-see.info\/wp\/wp-json\/wp\/v2\/tags?post=762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}