{"id":480,"date":"2013-08-29T06:36:30","date_gmt":"2013-08-29T06:36:30","guid":{"rendered":"http:\/\/oranotes.tuktaroff.com\/?page_id=480"},"modified":"2013-08-29T06:45:01","modified_gmt":"2013-08-29T06:45:01","slug":"vi-commands","status":"publish","type":"page","link":"http:\/\/oranotes.tuktaroff.com\/?page_id=480","title":{"rendered":"Vi commands"},"content":{"rendered":"<p><strong>Quitting<\/strong><\/p>\n<p>: x Exit, saving changes<br \/>\n:q Exit as long as there have been no changes<br \/>\nZZ Exit and save changes if any have been made<br \/>\n:q! Exit and ignore any changes<\/p>\n<p><strong>Inserting Text<\/strong><\/p>\n<p>i Insert before cursor<br \/>\nI Insert before line<br \/>\na Append after cursor<br \/>\nA Append after line<br \/>\no Open a new line after current line<br \/>\nO Open a new line before current line<br \/>\nr Replace one character<br \/>\nR Replace many characters<\/p>\n<p><strong>Motion<\/strong><br \/>\nh Move left<br \/>\nj Move down<br \/>\nk Move up<br \/>\nl Move right<br \/>\nw Move to next word<br \/>\nW Move to next blank delimited word<br \/>\nb Move to the beginning of the word<br \/>\nB Move to the beginning of blank delimted word<br \/>\ne Move to the end of the word<br \/>\nE Move to the end of Blank delimited word<br \/>\n( Move a sentence back<br \/>\n) Move a sentence forward<br \/>\n{ Move a paragraph back<br \/>\n} Move a paragraph forward<br \/>\n0 Move to the begining of the line<br \/>\n$ Move to the end of the line<br \/>\n1G Move to the first line of the file<br \/>\nG Move to the last line of the file<br \/>\nnG Move to nth line of the file<br \/>\n:n Move to nth line of the file<br \/>\nfc Move forward to c<br \/>\nFc Move back to c<br \/>\nH Move to top of screen<br \/>\nM Move to middle of screen<br \/>\nL Move to botton of screen<br \/>\n% Move to associated ( ), { }, [ ]<\/p>\n<p><strong>Deleting Text<\/strong><br \/>\nAlmost all deletion commands are performed by typing d followed by a motion. For example, dw deletes a word. A few other deletes are:<br \/>\nx Delete character to the right of cursor<br \/>\nX Delete character to the left of cursor<br \/>\nD Delete to the end of the line<br \/>\ndd Delete current line<br \/>\n:d Delete current line<\/p>\n<p>Like deletion, almost all yank commands are performed by typing y followed by a motion. For example, y$ yanks to the end of the line. Two other yank commands are:<br \/>\nyy Yank the current line<br \/>\n:y Yank the current line<\/p>\n<p><strong>Changing text<\/strong><br \/>\nThe change command is a deletion command that leaves the editor in insert mode.<br \/>\nIt is performed by typing c followed by a motion. For example cw changes a word. A few other change commands are:<br \/>\nC Change to the end of the line<br \/>\ncc Change the whole line<\/p>\n<p><strong>Putting text<\/strong><br \/>\np Put after the position or after the line<br \/>\nP Put before the poition or before the line<\/p>\n<p><strong>Buffers<\/strong><br \/>\nNamed buffers may be specified before any deletion, change, yank or put command.<br \/>\nThe general prefix has the form &#8220;c where c is any lowercase character. for example,<br \/>\n&#8220;adw deletes a word into buffer a. It may thereafter be put back into text with an appropriate &#8220;ap.<\/p>\n<p><strong>Markers<\/strong><br \/>\nNamed markers may be set on any line in a file. Any lower case letter may be a marker name. Markers may also be used as limits for ranges.<br \/>\nmc Set marker c on this line<br \/>\n`c Go to beginning of marker c line.<br \/>\n&#8216;c Go to first non-blank character of marker c line.<\/p>\n<p><strong>Search for strings<\/strong><br \/>\n\/string Search forward for string<br \/>\n?string Search back for string<br \/>\nn Search for next instance of string<br \/>\nN Search for previous instance of string<\/p>\n<p><strong>Replace<\/strong><br \/>\nThe search and replace function is accomplished with the :s command. It is commonly used in combination with ranges or the :g command (below).<br \/>\n:s\/pattern\/string\/flags Replace pattern with string according to flags.<br \/>\ng Flag &#8211; Replace all occurences of pattern<br \/>\nc Flag &#8211; Confirm replaces.<br \/>\n&amp; Repeat last :s command<\/p>\n<p><strong>Regular Expressions<\/strong><br \/>\n. (dot) Any single character except newline<br \/>\n* zero or more occurances of any character<br \/>\n[&#8230;] Any single character specified in the set<br \/>\n[^&#8230;] Any single character not specified in the set<br \/>\n^ Anchor &#8211; beginning of the line<br \/>\n$ Anchor &#8211; end of line<br \/>\n\\&lt; Anchor &#8211; begining of word \\&gt; Anchor &#8211; end of word<br \/>\n\\(&#8230;\\) Grouping &#8211; usually used to group conditions<br \/>\n\\n Contents of nth grouping<\/p>\n<p>[&#8230;] &#8211; Set Examples [A-Z] The SET from Capital A to Capital Z<br \/>\n[a-z] The SET from lowercase a to lowercase z<br \/>\n[0-9] The SET from 0 to 9 (All numerals)<br \/>\n[.\/=+] The SET containing . (dot), \/ (slash), =, and +<br \/>\n[-A-F] The SET from Capital A to Capital F and the dash (dashes must be specified first)<br \/>\n[0-9 A-Z] The SET containing all capital letters and digits and a space<br \/>\n[A-Z][a-zA-Z] In the first position, the SET from Capital A to Capital Z<br \/>\nIn the second character position, the SET containing all letters<\/p>\n<p>Regular Expression Examples \/Hello\/ Matches if the line contains the value Hello<br \/>\n\/^TEST$\/ Matches if the line contains TEST by itself<br \/>\n\/^[a-zA-Z]\/ Matches if the line starts with any letter<br \/>\n\/^[a-z].*\/ Matches if the first character of the line is a-z and there is at least one more of any character following it<br \/>\n\/2134$\/ Matches if line ends with 2134<br \/>\n\/\\(21|35\\)\/ Matches is the line contains 21 or 35<br \/>\nNote the use of ( ) with the pipe symbol to specify the &#8216;or&#8217; condition<br \/>\n\/[0-9]*\/ Matches if there are zero or more numbers in the line<br \/>\n\/^[^#]\/ Matches if the first character is not a # in the line<br \/>\nNotes:<br \/>\n1. Regular expressions are case sensitive<br \/>\n2. Regular expressions are to be used where pattern is specified<\/p>\n<p><strong>Counts<\/strong><br \/>\nNearly every command may be preceded by a number that specifies how many times it is to be performed. For example,<br \/>\n5dw will delete 5 words and 3fe will move the cursor forward to the 3rd occurence of the letter e.<br \/>\nEven insertions may be repeated conveniently with thismethod, say to insert the same line 100 times.<\/p>\n<p><strong>Ranges<\/strong><br \/>\nRanges may precede most &#8220;colon&#8221; commands and cause them to be executed on a line or lines.<br \/>\nFor example :3,7d would delete lines 3-7. Ranges are commonly combined with the :s command<br \/>\nto perform a replacement on several lines, as with :.,$s\/pattern\/string\/g to make a replacement from the current line to the end of the file.<br \/>\n:n,m Range &#8211; Lines n-m<br \/>\n:. Range &#8211; Current line<br \/>\n:$ Range &#8211; Last line<br \/>\n:&#8217;c Range &#8211; Marker c<br \/>\n:% Range &#8211; All lines in file<br \/>\n:g\/pattern\/ Range &#8211; All lines that contain pattern<\/p>\n<p><strong>Files<\/strong><br \/>\n:w file Write to file<br \/>\n:r file Read file in after line<br \/>\n:n Go to next file<br \/>\n:p Go to previos file<br \/>\n:e file Edit file<br \/>\n!!program Replace line with output from program<\/p>\n<p><strong>Other<\/strong><br \/>\n~ Toggle upp and lower case<br \/>\nJ Join lines<br \/>\n. Repeat last text-changing command<br \/>\nu Undo last change<br \/>\nU Undo all changes to line<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Quitting : x Exit, saving changes :q Exit as long as there have been no changes ZZ Exit and save changes if any have been made :q! Exit and ignore any changes Inserting Text i Insert before cursor I Insert before line a Append after cursor A Append after line o Open a new line [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":87,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-480","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/P2NVny-7K","_links":{"self":[{"href":"http:\/\/oranotes.tuktaroff.com\/index.php?rest_route=\/wp\/v2\/pages\/480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/oranotes.tuktaroff.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/oranotes.tuktaroff.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/oranotes.tuktaroff.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/oranotes.tuktaroff.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=480"}],"version-history":[{"count":6,"href":"http:\/\/oranotes.tuktaroff.com\/index.php?rest_route=\/wp\/v2\/pages\/480\/revisions"}],"predecessor-version":[{"id":486,"href":"http:\/\/oranotes.tuktaroff.com\/index.php?rest_route=\/wp\/v2\/pages\/480\/revisions\/486"}],"up":[{"embeddable":true,"href":"http:\/\/oranotes.tuktaroff.com\/index.php?rest_route=\/wp\/v2\/pages\/87"}],"wp:attachment":[{"href":"http:\/\/oranotes.tuktaroff.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}